Просмотр исходного кода

Merge branch 'master' of http://git.dongerkj.com:9095/waibao/NN2023021801

* 'master' of http://git.dongerkj.com:9095/waibao/NN2023021801:
  wes 多宝福袋
  wes 多宝福袋
  wes 多宝福袋
devolp 3 лет назад
Родитель
Сommit
8e4b877333
100 измененных файлов с 757 добавлено и 305 удалено
  1. 1 1
      app/admin/controller/Ajax.php
  2. 17 1
      app/admin/view/system/config/site.html
  3. 85 122
      app/api/command/AutoSubmeter.php
  4. 233 0
      app/api/command/AutoSubmeterBack.php
  5. 6 1
      app/api/command/SettleBoxReturn.php
  6. 5 5
      app/api/command/SettleTeamAward.php
  7. 32 30
      app/api/controller/h5/DownApp.php
  8. 9 18
      app/api/controller/h5/User.php
  9. 12 5
      app/api/controller/v1/Box.php
  10. 97 57
      app/api/controller/v1/Pay.php
  11. 18 17
      app/api/controller/v1/User.php
  12. 127 1
      app/api/services/ThirdPayServices.php
  13. 9 5
      app/common/model/MoneyLogModel.php
  14. 27 7
      app/common/service/BoxHandleService.php
  15. 18 8
      app/common/service/BoxRecordService.php
  16. 36 3
      app/common/service/PayConfigService.php
  17. 2 1
      app/common/service/PaymentService.php
  18. 2 0
      config/type.php
  19. 1 1
      public/h5/index.html
  20. BIN
      public/h5/static/images/common/check1.png
  21. BIN
      public/h5/static/images/common/checked1.png
  22. BIN
      public/h5/static/img/bg_chengwei_fuwushang@2x.f1c41f7f.png
  23. BIN
      public/h5/static/img/bg_denglu_dise@2x.10ae4faf.png
  24. BIN
      public/h5/static/img/bg_fudai_chaichu@2x.e20beca8.png
  25. BIN
      public/h5/static/img/bg_fudai_dise_one@2x.38bb749c.png
  26. BIN
      public/h5/static/img/bg_home_bottom.cef3191f.png
  27. BIN
      public/h5/static/img/bg_home_notice.000aa8aa.png
  28. BIN
      public/h5/static/img/bg_hudai_texiao@2x.bd406325.png
  29. BIN
      public/h5/static/img/bg_me_cenrer@2x.781e24c2.png
  30. BIN
      public/h5/static/img/bg_me_haoyou_ds@2x.a3125711.png
  31. BIN
      public/h5/static/img/bg_shengji@2x.30267671.png
  32. BIN
      public/h5/static/img/bg_yushou@2x.da1f0f03.png
  33. BIN
      public/h5/static/img/bt_me_fucang@2x.cc8e6296.png
  34. BIN
      public/h5/static/img/bt_me_yuyue@2x.866b6c73.png
  35. BIN
      public/h5/static/img/bt_xinshou_jiaochen@2x.3204d4ed.png
  36. BIN
      public/h5/static/img/ic_chaidai_fd@2x.1a3ed457.png
  37. BIN
      public/h5/static/img/ic_duobaofudai_d@2x.3953cc90.png
  38. BIN
      public/h5/static/img/ic_fahuo_diz.f83cb391.png
  39. BIN
      public/h5/static/img/ic_huishouka_fd@2x.8a3e0046.png
  40. BIN
      public/h5/static/img/ic_kefu_fd@2x.709f493c.png
  41. BIN
      public/h5/static/img/ic_lianxi_kh@2x.7a9eaec5.png
  42. BIN
      public/h5/static/img/ic_paopao_two@2x.bdccc9ca.png
  43. BIN
      public/h5/static/img/ic_time_fd@2x.eea1ebc0.png
  44. BIN
      public/h5/static/img/ic_wenxintishi@2x.5a5ab06c.png
  45. BIN
      public/h5/static/img/ic_xinshou_zhiyin@2x.53075e16.png
  46. BIN
      public/h5/static/img/subscribe.372ade69.gif
  47. 1 1
      public/h5/static/js/index.a22b3d45.js
  48. 1 0
      public/h5/static/js/pages-index-index.51eb4d5f.js
  49. 0 1
      public/h5/static/js/pages-index-index.a9515edd.js
  50. 0 1
      public/h5/static/js/pages-login-login.3530f383.js
  51. 1 0
      public/h5/static/js/pages-login-login.f438e24f.js
  52. 1 0
      public/h5/static/js/pages-login-register.2c865ac7.js
  53. 0 1
      public/h5/static/js/pages-login-register.39b21002.js
  54. 0 1
      public/h5/static/js/pages-me-me.9490a009.js
  55. 1 0
      public/h5/static/js/pages-me-me.a84ece74.js
  56. 0 1
      public/h5/static/js/pages-sweepstakes-sweepstakes.ab3c8f3e.js
  57. 1 0
      public/h5/static/js/pages-sweepstakes-sweepstakes.e5b58d41.js
  58. 0 1
      public/h5/static/js/pages-warehouse-warehouse.9b62782d.js
  59. 1 0
      public/h5/static/js/pages-warehouse-warehouse.9eccef5b.js
  60. 1 0
      public/h5/static/js/pagesGoods-goodsDetail-goodsDetail.7b32a3a2.js
  61. 0 1
      public/h5/static/js/pagesGoods-goodsDetail-goodsDetail.f800edc5.js
  62. 1 0
      public/h5/static/js/pagesGoods-order-orderSubmit.587c977b.js
  63. 0 1
      public/h5/static/js/pagesGoods-order-orderSubmit.d0d6f217.js
  64. 0 1
      public/h5/static/js/pagesGoods-sweepstakes-sweepstakesGoods.2f0fa0c4.js
  65. 1 0
      public/h5/static/js/pagesGoods-sweepstakes-sweepstakesGoods.a4a075d2.js
  66. 0 1
      public/h5/static/js/pagesUser-asset-balance.48ead5b8.js
  67. 1 0
      public/h5/static/js/pagesUser-asset-balance.c0722d3d.js
  68. 1 0
      public/h5/static/js/pagesUser-asset-withdraw.daa3c516.js
  69. 0 1
      public/h5/static/js/pagesUser-asset-withdraw.e453a298.js
  70. 2 2
      public/h5/static/js/pagesUser-chat-chat.4f71af2b.js
  71. 1 0
      public/h5/static/js/pagesUser-message-notice.5057d2dd.js
  72. 0 1
      public/h5/static/js/pagesUser-message-notice.af6228da.js
  73. 0 1
      public/h5/static/js/pagesUser-setting-about.0c3b2b2f.js
  74. 1 0
      public/h5/static/js/pagesUser-setting-about.237efffd.js
  75. 1 0
      public/h5/static/js/pagesUser-team-team.02e25bc1.js
  76. 0 1
      public/h5/static/js/pagesUser-team-team.71bc607f.js
  77. 0 0
      public/static/admin/images/cate_all.png
  78. 0 0
      public/static/admin/images/chajiu.png
  79. 0 0
      public/static/admin/images/fushi.png
  80. 0 0
      public/static/admin/images/jiadian.png
  81. 0 0
      public/static/admin/images/jinping.jpg
  82. 0 0
      public/static/admin/images/lingshi.png
  83. 0 0
      public/static/admin/images/loginbg1.jpeg
  84. 0 0
      public/static/admin/images/loginbg12.png
  85. 0 0
      public/static/admin/images/shoushi.png
  86. 0 0
      public/static/admin/images/shuma.png
  87. 0 0
      public/static/admin/images/tehui.jpg
  88. 0 0
      public/static/admin/images/tiyan.jpg
  89. 0 0
      public/static/admin/images/xiangbao.png
  90. 0 0
      public/static/admin/images/xinshou.jpg
  91. 0 0
      public/static/admin/images/yushi.png
  92. 0 0
      public/static/admin/images/zhongbiao.png
  93. 0 0
      public/static/admin/js/box/appoint_list.js
  94. 0 0
      public/static/admin/js/box/box.js
  95. 0 0
      public/static/admin/js/box/handle_box_action.js
  96. 0 0
      public/static/admin/js/box/matching_box.js
  97. 2 5
      public/static/admin/js/box/open_box_action.js
  98. 0 0
      public/static/admin/js/user/recharge.js
  99. 1 0
      public/static/admin/js/user/user.js
  100. 0 0
      public/static/api/image/user/ic_dl_logo@3x.png

+ 1 - 1
app/admin/controller/Ajax.php

@@ -64,7 +64,7 @@ class Ajax extends AdminController
         RedisCache::keyDel("caches:goods*");
 
         // 其他临时缓存
-        RedisCache::keyDel("caches:temp*");
+        RedisCache::keyDel("caches:tem*");
         Cache::clear();
         $this->success('清理缓存成功');
     }

+ 17 - 1
app/admin/view/system/config/site.html

@@ -28,8 +28,24 @@
     </div>
 
     <div class="layui-form-item">
+        <label class="layui-form-label">安卓APP地址</label>
+        <div class="layui-input-block">
+            <input type="text" name="site_android_url" class="layui-input" placeholder="请输入安卓APP下载地址" value="{:sysconfig('site','site_android_url')}">
+            <tip>填写安卓APP下载地址。</tip>
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label">苹果APP地址</label>
+        <div class="layui-input-block">
+            <input type="text" name="site_ios_url" class="layui-input"  placeholder="请输入平果APP下载地址" value="{:sysconfig('site','site_ios_url')}">
+            <tip>填写苹果APP下载地址。</tip>
+        </div>
+    </div>
+
+    <div class="layui-form-item">
         <label class="layui-form-label">站点名称</label>
-        <div class="layui-input-block">app/admin/view/system/config/index.html
+        <div class="layui-input-block">
             <input type="text" name="site_name" class="layui-input" lay-verify="required" placeholder="请输入站点名称" value="{:sysconfig('site','site_name')}">
             <tip>填写站点名称。</tip>
         </div>

+ 85 - 122
app/api/command/AutoSubmeter.php

@@ -1,5 +1,5 @@
 <?php
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\api\command;
 
@@ -20,11 +20,11 @@ class AutoSubmeter extends Command
     protected $cacheTime = 86400; // 一天
     protected $tables = [
         // time 备份分表周期,save_time 数据保存时间天,time_field 时间字段
-        'money_log'=>['time'=>2, 'save_time'=> 14,'time_field'=>'create_at'],
-        'box_record'=>['time'=>2, 'save_time'=> 10,'time_field'=>'create_time'],
-        'box_mid_handle'=>['time'=>2, 'save_time'=> 10,'time_field'=>'create_time'],
-        'score_log'=>['time'=>2, 'save_time'=> 10,'time_field'=>'create_at'],
-        'box_handle'=>['time'=>1, 'save_time'=> 0,'time_field'=>'create_time'],
+        'money_log' => ['time' => 2, 'save_time' => 14, 'time_field' => 'create_at'],
+        'box_record' => ['time' => 2, 'save_time' => 10, 'time_field' => 'create_time'],
+        'box_mid_handle' => ['time' => 2, 'save_time' => 10, 'time_field' => 'create_time'],
+        'score_log' => ['time' => 2, 'save_time' => 10, 'time_field' => 'create_at'],
+//        'box_handle'=>['time'=>1, 'save_time'=> 0,'time_field'=>'create_time'],
     ];
 
     protected function configure()
@@ -41,13 +41,14 @@ class AutoSubmeter extends Command
      */
     protected function execute(Input $input, Output $output)
     {
-        if(date('H:i') > '08:00'){
-            echo json_encode(['code'=>500,'msg'=>'不在运行时间段内,请于早上0点~8点执行','date'=>date('Y-m-d H:i:s')], 256)."\n";
+        set_time_limit(0);
+        if (date('H:i') > '12:00') {
+            echo json_encode(['code' => 500, 'msg' => '不在运行时间段内,请于早上0点~8点执行', 'date' => date('Y-m-d H:i:s')], 256) . "\n";
             return false;
         }
 
-        if(RedisCache::get("caches:submeter:lock")){
-            echo json_encode(['code'=>500,'msg'=>'请不要频繁执行,稍后再试~','date'=>date('Y-m-d H:i:s')], 256)."\n";
+        if (RedisCache::get("caches:submeter:lock")) {
+            echo json_encode(['code' => 500, 'msg' => '请不要频繁执行,稍后再试~', 'date' => date('Y-m-d H:i:s')], 256) . "\n";
             return false;
         }
 
@@ -65,122 +66,84 @@ class AutoSubmeter extends Command
 
                 // 验证是否备份
                 $dateTime = strtotime(date('Y-m-d')) - 86400;
-                if($tableName == 'box_handle'){
-                    $index = 'all';
-                    $newTableName = $tableName . '_' . $index;
-                    $date = date('Y-m-d H:i:s', $dateTime);
-
-                    if ($this->checkCatchByTime($tableName, $index, $time)) {
-                        $hasCount++;
-                        RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item,'name'=>$newTableName, 'error' => '未到备份时间间隔'], $this->cacheTime);
-                        continue;
-                    }
-
-                    // 复制数据
-                    $prefix = env('database.prefix','db_');
-                    $count1 = Db::name($tableName)->where('is_delete', 2)->whereNotIn('id',Db::name($newTableName)->column('id'))->count();
-                    if(!$count1){
-                        $hasCount++;
-                        RedisCache::set($cacheKey . "{$newTableName}_error", ['sql'=>Db::name($tableName)->getLastSql(),'count'=>$count1,'data' => $item,'name'=>$newTableName, 'error' => '没有数据处理'], $this->cacheTime);
-                        continue;
-                    }
-
-                    $count2 = Db::name($newTableName)->count();
-                    $sql = "insert into `{$prefix}{$newTableName}` (select * from `{$prefix}{$tableName}` where `id` not in (select `id` from `{$prefix}{$newTableName}`) and `is_delete` = 2 and `create_time` < '".date('Y-m-d')."')";
-                    $res = Db::query($sql);
-                    $count3 = Db::name($newTableName)->count();
-                    if (($count3 - $count2) < $count1) {
-                        RedisCache::set($cacheKey."{$newTableName}_error", ['count'=>$count,'sql1'=>$sql,'msg'=> '复制分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
-                        sr_throw("复制[{$newTableName}]分表数据错误");
-                    }
-
-                    // 清理原表多余数据
-                    Db::name($tableName)->where(['is_delete'=>1])->where('update_time','<',$date)->delete();
-                    $res = Db::name($tableName)->whereIn('id',Db::name($newTableName)->column('id'))->update(['is_delete'=>1,'update_time'=>date('Y-m-d H:i:s')]);
-                    if(!$res){
-                        RedisCache::set($cacheKey."{$newTableName}_error", ['count'=>$count,'sql'=>$sql,'sql1'=>Db::name($tableName)->getLastSql(),'msg'=> '清理备份分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
-                        sr_throw("清理[{$tableName}]表旧数据错误");
-                    }
-                }else{
-                    $index = date('Ymd', $dateTime);
-                    $newTableName = $tableName . '_' . $index;
-                    if ($this->checkCatchByTime($tableName, $index, $time)) {
-                        $hasCount++;
-                        RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item,'name'=>$newTableName, 'error' => '未到备份时间间隔'], $this->cacheTime);
-                        continue;
-                    }
-
-                    if ($this->checkCatch($tableName, $index)) {
-                        $hasCount++;
-                        RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item,'name'=>$newTableName, 'error' => '已经处理过'], $this->cacheTime);
-                        continue;
-                    }
-
-                    // 备份处理(1:复制表,2-清除日期间隔数据)
-                    $prefix = env('database.prefix','db_');
-                    $date = date('Y-m-d H:i:s', $dateTime);
-
-                    // 复制表结构
-                    $sql = "create table IF not exists `{$prefix}{$newTableName}` like `{$prefix}{$tableName}`";
-                    Db::query($sql);
-
-                    // 复制数据
-                    $count1 = Db::name($tableName)->count();
-                    $sql1 = "insert ignore `{$prefix}{$newTableName}` select * from `{$prefix}{$tableName}`";
-                    Db::query($sql1);
-                    if ($count1 != Db::name($newTableName)->count()) {
-                        RedisCache::set($cacheKey."{$newTableName}_error", ['sql'=>$sql,'sql1'=>$sql1,'msg'=> '复制分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
-                        sr_throw("复制备份[{$newTableName}]分表数据错误");
-                    }
-
-                    // 清理原表多余数据
-                    $expiredRow = Db::name($tableName)
-                        ->where($timeField,'<', $date)
-                        ->where(function ($query) use($tableName){
-                            if($tableName == 'money_log'){
-                                $query->whereNotIn('type', [8]);
-                            }
-                        })
-                        ->count();
-
-                    $isDelete = Db::name($tableName)
-                        ->where($timeField,'<', $date)
-                        ->where(function ($query) use($tableName){
-                            if($tableName == 'money_log'){
-                                $query->whereNotIn('type', [8]);
-                            }
-                        })
-                        ->delete();
-                    if($expiredRow && !$isDelete){
-                        RedisCache::set($cacheKey."{$newTableName}_error", ['sql'=>$sql,'msg'=> '清理备份分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
-                        sr_throw("清理[{$tableName}]表旧数据错误");
-                    }
+
+                $index = date('Ymd', $dateTime);
+                $newTableName = $tableName . '_' . $index;
+                if ($this->checkCatchByTime($tableName, $index, $time)) {
+                    $hasCount++;
+                    RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item, 'name' => $newTableName, 'error' => '未到备份时间间隔'], $this->cacheTime);
+                    continue;
+                }
+
+                if ($this->checkCatch($tableName, $index)) {
+                    $hasCount++;
+                    RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item, 'name' => $newTableName, 'error' => '已经处理过'], $this->cacheTime);
+                    continue;
                 }
 
+                // 备份处理(1:复制表,2-清除日期间隔数据)
+                $prefix = env('database.prefix', 'db_');
+                $date = date('Y-m-d H:i:s', $dateTime);
+
+                // 复制表结构
+                $sql = "create table IF not exists `{$prefix}{$newTableName}` like `{$prefix}{$tableName}`";
+                Db::query($sql);
+
+                // 复制数据
+                $count1 = Db::name($tableName)->count();
+                $sql1 = "insert ignore `{$prefix}{$newTableName}` select * from `{$prefix}{$tableName}`";
+                Db::query($sql1);
+                if ($count1 != Db::name($newTableName)->count()) {
+                    RedisCache::set($cacheKey . "{$newTableName}_error", ['sql' => $sql, 'sql1' => $sql1, 'count1' => $count1, 'msg' => '复制分表数据错误', 'data' => $item, 'date' => date('Y-m-d H:i:s')], $this->cacheTime);
+                    sr_throw("复制备份[{$newTableName}]分表数据错误");
+                }
+
+                // 清理原表多余数据
+                $expiredRow = Db::name($tableName)
+                    ->where($timeField, '<', $date)
+                    ->where(function ($query) use ($tableName) {
+                        if ($tableName == 'money_log') {
+                            $query->whereNotIn('type', [8]);
+                        }
+                    })
+                    ->count();
+
+                $isDelete = Db::name($tableName)
+                    ->where($timeField, '<', $date)
+                    ->where(function ($query) use ($tableName) {
+                        if ($tableName == 'money_log') {
+                            $query->whereNotIn('type', [8]);
+                        }
+                    })
+                    ->delete();
+                if ($expiredRow && !$isDelete) {
+                    RedisCache::set($cacheKey . "{$newTableName}_error", ['sql' => $sql, 'msg' => '清理备份分表数据错误', 'count' => $expiredRow, 'data' => $item, 'date' => date('Y-m-d H:i:s')], $this->cacheTime);
+                    sr_throw("清理[{$tableName}]表旧数据错误");
+                }
 
                 $data = [
-                    'table_name'=> $tableName,
-                    'table_index'=> $index,
-                    'update_time'=> date('Y-m-d H:i:s'),
-                    'expired_at'=> $saveTime?date('Y-m-d H:i:s', time() + $saveTime * 24 * 3600):'',
-                    'status'=>1
+                    'table_name' => $tableName,
+                    'table_index' => $index,
+                    'update_time' => date('Y-m-d H:i:s'),
+                    'expired_at' => $saveTime ? date('Y-m-d H:i:s', time() + $saveTime * 24 * 3600) : '',
+                    'status' => 1
                 ];
-                if(!SubmeterModel::insertGetId($data)){
-                    RedisCache::set($cacheKey."{$newTableName}_error", ['sql'=>$sql,'msg'=> '处理分表记录错误','log'=>$data,'data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                if (!SubmeterModel::insertGetId($data)) {
+                    RedisCache::set($cacheKey . "{$newTableName}_error", ['sql' => $sql, 'msg' => '处理分表记录错误', 'log' => $data, 'data' => $item, 'date' => date('Y-m-d H:i:s')], $this->cacheTime);
                     sr_throw("处理[{$newTableName}]分表记录错误");
                 }
 
-                RedisCache::set($cacheKey."{$newTableName}_success", ['sql'=>$sql,'msg'=> '处理分表备份成功','log'=>$data,'data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                RedisCache::set($cacheKey . "{$newTableName}_success", ['sql' => $sql, 'msg' => '处理分表备份成功', 'log' => $data, 'data' => $item, 'date' => date('Y-m-d H:i:s')], $this->cacheTime);
                 $count++;
             }
 
             Db::commit();
-            echo json_encode(['code'=>200,'msg'=>"运行成功:共处理{$count}个表备份,{$hasCount}个已备份过",'date'=>date('Y-m-d H:i:s')],256)."\n";
-        }catch (\Exception $exception){
+            echo json_encode(['code' => 200, 'msg' => "运行成功:共处理{$count}个表备份,{$hasCount}个已备份过", 'date' => date('Y-m-d H:i:s')], 256) . "\n";
+        } catch (\Exception $exception) {
             Db::rollback();
             RedisCache::clear("caches:submeter:lock");
-            RedisCache::set("caches:submeter:error", ['msg'=> '运行错误:'.$exception->getMessage(),'trace'=>$exception->getTrace(),'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
-            echo json_encode(['code'=>500,'msg'=>'运行错误:'.$exception->getMessage(),'date'=>date('Y-m-d H:i:s')], 256)."\n";
+            RedisCache::set("caches:submeter:error", ['msg' => '运行错误:' . $exception->getMessage(), 'trace' => $exception->getTrace(), 'date' => date('Y-m-d H:i:s')], $this->cacheTime);
+            echo json_encode(['code' => 500, 'msg' => '运行错误:' . $exception->getMessage(), 'date' => date('Y-m-d H:i:s')], 256) . "\n";
         }
 
         return true;
@@ -194,12 +157,12 @@ class AutoSubmeter extends Command
     protected function checkCatch($tableName, $index)
     {
         $cacheKey = "caches:submeter:check:{$tableName}_{$index}";
-        if(RedisCache::get($cacheKey)){
+        if (RedisCache::get($cacheKey)) {
             return true;
         }
 
-        $data = SubmeterModel::where(['table_name'=> $tableName,'table_index'=>$index,'status'=>1])->value('id');
-        if($data){
+        $data = SubmeterModel::where(['table_name' => $tableName, 'table_index' => $index, 'status' => 1])->value('id');
+        if ($data) {
             RedisCache::set($cacheKey, $data, rand(10, 20));
         }
 
@@ -214,16 +177,16 @@ class AutoSubmeter extends Command
     protected function checkCatchByTime($tableName, $index, $day)
     {
         $cacheKey = "caches:submeter:check:time_{$tableName}_{$index}_{$day}";
-        if(RedisCache::get($cacheKey)){
-//            return true;
+        if (RedisCache::get($cacheKey)) {
+            return true;
         }
 
-        $date = $day == 1? date('Y-m-d') : date('Y-m-d H:i:s', time() - $day * 24 * 3600);
-        $data = SubmeterModel::where(['table_name'=> $tableName,'status'=>1])
-            ->where('update_time','>=', $date)
+        $date = $day == 1 ? date('Y-m-d') : date('Y-m-d H:i:s', time() - $day * 24 * 3600);
+        $data = SubmeterModel::where(['table_name' => $tableName, 'status' => 1])
+            ->where('update_time', '>=', $date)
             ->value('id');
-var_dump(SubmeterModel::getLastSql());
-        if($data){
+        //var_dump(SubmeterModel::getLastSql());
+        if ($data) {
             RedisCache::set($cacheKey, $data, rand(10, 20));
         }
 

+ 233 - 0
app/api/command/AutoSubmeterBack.php

@@ -0,0 +1,233 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\api\command;
+
+use app\common\model\SubmeterModel;
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use think\facade\Db;
+use utils\RedisCache;
+
+/**
+ * 自动分表备份 by wes 每天凌晨 0点后运行,运行两次间隔10分钟
+ * Class AutoSubmeter
+ * @package app\api\command
+ */
+class AutoSubmeter extends Command
+{
+    protected $cacheTime = 86400; // 一天
+    protected $tables = [
+        // time 备份分表周期,save_time 数据保存时间天,time_field 时间字段
+        'money_log'=>['time'=>2, 'save_time'=> 14,'time_field'=>'create_at'],
+        'box_record'=>['time'=>2, 'save_time'=> 10,'time_field'=>'create_time'],
+        'box_mid_handle'=>['time'=>2, 'save_time'=> 10,'time_field'=>'create_time'],
+        'score_log'=>['time'=>2, 'save_time'=> 10,'time_field'=>'create_at'],
+//        'box_handle'=>['time'=>1, 'save_time'=> 0,'time_field'=>'create_time'],
+    ];
+
+    protected function configure()
+    {
+        $this->setName('auto_backup_submeter')
+            ->setDescription('the auto_backup_submeter command');
+    }
+
+    /**
+     * 处理分表
+     * @param Input $input
+     * @param Output $output
+     * @return int
+     */
+    protected function execute(Input $input, Output $output)
+    {
+        set_time_limit(0);
+        if(date('H:i') > '12:00'){
+            echo json_encode(['code'=>500,'msg'=>'不在运行时间段内,请于早上0点~8点执行','date'=>date('Y-m-d H:i:s')], 256)."\n";
+            return false;
+        }
+
+        if(RedisCache::get("caches:submeter:lock")){
+            echo json_encode(['code'=>500,'msg'=>'请不要频繁执行,稍后再试~','date'=>date('Y-m-d H:i:s')], 256)."\n";
+            return false;
+        }
+
+        RedisCache::setnx("caches:submeter:lock", date('Y-m-d H:i:s'), rand(10, 20));
+        Db::startTrans();
+        try {
+            $count = 0;
+            $hasCount = 0;
+            $cacheKey = "caches:submeter:backup:";
+            foreach ($this->tables as $tableName => $item) {
+                $time = isset($item['time']) ? $item['time'] : 0; // 备份周期
+                $saveTime = isset($item['save_time']) ? $item['save_time'] : 0; // 保存时间
+                $timeField = isset($item['time_field']) ? $item['time_field'] : 0; // 时间字段
+                $time = $time ? $time : 2;
+
+                // 验证是否备份
+                $dateTime = strtotime(date('Y-m-d')) - 86400;
+                if($tableName == 'box_handle'){
+                    $index = 'all';
+                    $newTableName = $tableName . '_' . $index;
+                    $date = date('Y-m-d H:i:s', $dateTime);
+
+                    if ($this->checkCatchByTime($tableName, $index, $time)) {
+                        $hasCount++;
+                        RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item,'name'=>$newTableName, 'error' => '未到备份时间间隔'], $this->cacheTime);
+                        continue;
+                    }
+
+                    // 复制数据
+                    $prefix = env('database.prefix','db_');
+                    $count1 = Db::name($tableName)->where('is_delete', 2)->whereNotIn('id',Db::name($newTableName)->column('id'))->count();
+                    if(!$count1){
+                        $hasCount++;
+                        RedisCache::set($cacheKey . "{$newTableName}_error", ['count1'=>$count1,'sql'=>Db::name($tableName)->getLastSql(),'count'=>$count1,'data' => $item,'name'=>$newTableName, 'error' => '没有数据处理'], $this->cacheTime);
+                        continue;
+                    }
+
+                    $count2 = Db::name($newTableName)->count();
+                    $sql = "insert into `{$prefix}{$newTableName}` (select * from `{$prefix}{$tableName}` where `id` not in (select `id` from `{$prefix}{$newTableName}`) and `is_delete` = 2 and `create_time` < '".date('Y-m-d')."')";
+                    $res = Db::query($sql);
+                    $count3 = Db::name($newTableName)->count();
+                    if (($count3 - $count2) < $count1) {
+                        RedisCache::set($cacheKey."{$newTableName}_error", ['count2'=>$count2,'count3'=>$count3,'sql1'=>$sql,'msg'=> '复制分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                        sr_throw("复制[{$newTableName}]分表数据错误");
+                    }
+
+                    // 清理原表多余数据
+                    Db::name($tableName)->where(['is_delete'=>1])->where('update_time','<',$date)->delete();
+                    $res = Db::name($tableName)->whereIn('id',Db::name($newTableName)->column('id'))->update(['is_delete'=>1,'update_time'=>date('Y-m-d H:i:s')]);
+                    if(!$res){
+                        RedisCache::set($cacheKey."{$newTableName}_error", ['count'=>$count,'sql'=>$sql,'sql1'=>Db::name($tableName)->getLastSql(),'msg'=> '清理备份分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                        sr_throw("清理[{$tableName}]表旧数据错误");
+                    }
+                }else{
+                    $index = date('Ymd', $dateTime);
+                    $newTableName = $tableName . '_' . $index;
+                    if ($this->checkCatchByTime($tableName, $index, $time)) {
+                        $hasCount++;
+                        RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item,'name'=>$newTableName, 'error' => '未到备份时间间隔'], $this->cacheTime);
+                        continue;
+                    }
+
+                    if ($this->checkCatch($tableName, $index)) {
+                        $hasCount++;
+                        RedisCache::set($cacheKey . "{$newTableName}_error", ['data' => $item,'name'=>$newTableName, 'error' => '已经处理过'], $this->cacheTime);
+                        continue;
+                    }
+
+                    // 备份处理(1:复制表,2-清除日期间隔数据)
+                    $prefix = env('database.prefix','db_');
+                    $date = date('Y-m-d H:i:s', $dateTime);
+
+                    // 复制表结构
+                    $sql = "create table IF not exists `{$prefix}{$newTableName}` like `{$prefix}{$tableName}`";
+                    Db::query($sql);
+
+                    // 复制数据
+                    $count1 = Db::name($tableName)->count();
+                    $sql1 = "insert ignore `{$prefix}{$newTableName}` select * from `{$prefix}{$tableName}`";
+                    Db::query($sql1);
+                    if ($count1 != Db::name($newTableName)->count()) {
+                        RedisCache::set($cacheKey."{$newTableName}_error", ['sql'=>$sql,'sql1'=>$sql1,'count1'=>$count1,'msg'=> '复制分表数据错误','data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                        sr_throw("复制备份[{$newTableName}]分表数据错误");
+                    }
+
+                    // 清理原表多余数据
+                    $expiredRow = Db::name($tableName)
+                        ->where($timeField,'<', $date)
+                        ->where(function ($query) use($tableName){
+                            if($tableName == 'money_log'){
+                                $query->whereNotIn('type', [8]);
+                            }
+                        })
+                        ->count();
+
+                    $isDelete = Db::name($tableName)
+                        ->where($timeField,'<', $date)
+                        ->where(function ($query) use($tableName){
+                            if($tableName == 'money_log'){
+                                $query->whereNotIn('type', [8]);
+                            }
+                        })
+                        ->delete();
+                    if($expiredRow && !$isDelete){
+                        RedisCache::set($cacheKey."{$newTableName}_error", ['sql'=>$sql,'msg'=> '清理备份分表数据错误','count'=>$expiredRow,'data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                        sr_throw("清理[{$tableName}]表旧数据错误");
+                    }
+                }
+
+
+                $data = [
+                    'table_name'=> $tableName,
+                    'table_index'=> $index,
+                    'update_time'=> date('Y-m-d H:i:s'),
+                    'expired_at'=> $saveTime?date('Y-m-d H:i:s', time() + $saveTime * 24 * 3600):'',
+                    'status'=>1
+                ];
+                if(!SubmeterModel::insertGetId($data)){
+                    RedisCache::set($cacheKey."{$newTableName}_error", ['sql'=>$sql,'msg'=> '处理分表记录错误','log'=>$data,'data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                    sr_throw("处理[{$newTableName}]分表记录错误");
+                }
+
+                RedisCache::set($cacheKey."{$newTableName}_success", ['sql'=>$sql,'msg'=> '处理分表备份成功','log'=>$data,'data'=> $item,'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+                $count++;
+            }
+
+            Db::commit();
+            echo json_encode(['code'=>200,'msg'=>"运行成功:共处理{$count}个表备份,{$hasCount}个已备份过",'date'=>date('Y-m-d H:i:s')],256)."\n";
+        }catch (\Exception $exception){
+            Db::rollback();
+            RedisCache::clear("caches:submeter:lock");
+            RedisCache::set("caches:submeter:error", ['msg'=> '运行错误:'.$exception->getMessage(),'trace'=>$exception->getTrace(),'date'=>date('Y-m-d H:i:s')], $this->cacheTime);
+            echo json_encode(['code'=>500,'msg'=>'运行错误:'.$exception->getMessage(),'date'=>date('Y-m-d H:i:s')], 256)."\n";
+        }
+
+        return true;
+    }
+
+    /**
+     * 验证是否备份分表过
+     * @param $tableName 表名
+     * @return bool|mixed
+     */
+    protected function checkCatch($tableName, $index)
+    {
+        $cacheKey = "caches:submeter:check:{$tableName}_{$index}";
+        if(RedisCache::get($cacheKey)){
+            return true;
+        }
+
+        $data = SubmeterModel::where(['table_name'=> $tableName,'table_index'=>$index,'status'=>1])->value('id');
+        if($data){
+            RedisCache::set($cacheKey, $data, rand(10, 20));
+        }
+
+        return $data;
+    }
+
+    /**
+     * 验证是否备份分表过
+     * @param $tableName 表名
+     * @return bool|mixed
+     */
+    protected function checkCatchByTime($tableName, $index, $day)
+    {
+        $cacheKey = "caches:submeter:check:time_{$tableName}_{$index}_{$day}";
+        if(RedisCache::get($cacheKey)){
+            return true;
+        }
+
+        $date = $day == 1? date('Y-m-d') : date('Y-m-d H:i:s', time() - $day * 24 * 3600);
+        $data = SubmeterModel::where(['table_name'=> $tableName,'status'=>1])
+            ->where('update_time','>=', $date)
+            ->value('id');
+        //var_dump(SubmeterModel::getLastSql());
+        if($data){
+            RedisCache::set($cacheKey, $data, rand(10, 20));
+        }
+
+        return $data;
+    }
+}

+ 6 - 1
app/api/command/SettleBoxReturn.php

@@ -43,6 +43,11 @@ class SettleBoxReturn extends Command
             return false;
         }
 
+        if(date('H:i') <= '08:00' || (date('H:i')>'14:00' && date('H:i')<'15:00')||(date('H:i')>'19:00' && date('H:i') < '20:00')){
+            echo json_encode(['code'=>'error','msg'=>'不在结算时间段9:00~14:00/15:00~19:00/20:00~24:00内~','date'=>date('Y-m-d H:i:s')])."\n";
+            return false;
+        }
+
         RedisCache::setnx($cacheKey.'_lock', date('Y-m-d H:i:s'), rand(5, 10));
         Db::startTrans();
         try {
@@ -80,7 +85,7 @@ class SettleBoxReturn extends Command
             ->select();
         $boxList = $boxList? $boxList->toArray() : [];
         if(empty($boxList)){
-            return ['code'=>500,'msg'=>'暂无数据处理','date'=>$date];
+            return ['code'=>500,'msg'=>'暂无数据处理','sql'=>BoxMidHandleModel::getLastSql(),'date'=>$date];
         }
 
         $scoreCount = $moneyCount = 0;

+ 5 - 5
app/api/command/SettleTeamAward.php

@@ -138,7 +138,7 @@ class SettleTeamAward extends Command
                         'from_id'=> $boxId,
                         'uid2'=> $uid,
                         'free_type'=> 0,
-                        'remark'=> '直推1个福袋奖金'.($todayZtMoney>0? ',有今日奖金':'')
+                        'remark'=> "V{$pLevel}直推1个福袋奖金".($todayZtMoney>0? ",有今日奖金{$todayZtMoney}":'')
                     ];
                     $moneyLogs[] = $log;
                     if(!UserModel::where('id', $pid)->inc('money', $ztAward)->inc('today_money', $todayZtMoney)->update()){
@@ -211,7 +211,7 @@ class SettleTeamAward extends Command
                         if($tLevel == $tLastLevel){
                             $sameAward = isset($teamMoneys[$tLastId])? floatval($teamMoneys[$tLastId]) : 0;
                             $sameTeamAward = round($sameAward * 0.1, 2);
-                            $sameTeamAward = $sameTeamAward>0.1? $sameTeamAward : 0;
+                            $sameTeamAward = $sameTeamAward>=0.1? $sameTeamAward : 0;
                             if($sameTeamAward>0){
                                 $teamMoneys[$tId] = $sameTeamAward;
                             }
@@ -234,9 +234,9 @@ class SettleTeamAward extends Command
                             'before_money'=> $tMoney,
                             'after_money'=> floatval($tMoney + $endTeamAward),
                             'from_id'=> $boxId,
-                            'uid2'=> $sameTeamAward? $tLastId : 0,
-                            'free_type'=> 0,
-                            'remark'=> ($sameTeamAward? '1个福袋平级奖':'1个福袋团队奖').($tTodayAward>0? ',有今日奖金':'')
+                            'uid2'=> $sameTeamAward? $tLastId : $uid,
+                            'free_type'=> $sameTeamAward? 0 : 1,
+                            'remark'=> ($sameTeamAward? "V{$tLevel}得[ID:{$tLastId}]1个福袋平级奖":"V{$tLevel}得[ID:{$uid}]1个福袋团队奖").($tTodayAward>0? ",有今日奖金{$tTodayAward}":'')
                         ];
                         $moneyLogs[] = $log;
                         if(!UserModel::where('id', $tId)->inc('money', $endTeamAward)->inc('today_money', $tTodayAward)->update()){

+ 32 - 30
app/api/controller/h5/DownApp.php

@@ -5,6 +5,7 @@ namespace app\api\controller\h5;
 use app\api\services\UserServices;
 use app\api\validate\UserValidate;
 use app\common\model\SystemArticleModel;
+use app\common\service\SystemConfigService;
 use app\Request;
 use think\Exception;
 use think\exception\ValidateException;
@@ -21,70 +22,71 @@ class DownApp
         $this->service = $services;
     }
 
-    // 下载app
+    /**
+     * 下载app
+     * @param Request $request
+     * @return string
+     */
     public function downapp (Request $request)
     {
-//        // 这是测试 上线要干掉
-//            echo '网站正在升级中';
-//            die();
 
+        $config = SystemConfigService::make()->getConfigByNames(['site_android_url','site_ios_url'],1,'site');
+        $androidUrl = isset($config['site_android_url'])?$config['site_android_url'] : env('app.DOWN_ANDROID_URL_GENERAL');
+        $iosdUrl = isset($config['site_ios_url'])?$config['site_ios_url'] : env('app.DOWN_IOS_URL');
 
-        $a_url = env('app.DOWN_ANDROID_URL_GENERAL');
-        $i_url = env('app.DOWN_IOS_URL');
-
-        $is_fair = false; // 是否是浏览器
+        $isFair = false; // 是否是浏览器
         if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') === !1) {
-            $is_fair = true;
+            $isFair = true;
         }
         View::assign([
-            'is_fair' => $is_fair,
+            'is_fair' => $isFair,
             'k' => $request->param('k', ''),
             'v' => $request->param('v', ''),
         ]);
 
-        View::assign('aurl', $a_url);
-        View::assign('iurl', $i_url);
+        View::assign('aurl', $androidUrl);
+        View::assign('iurl', $iosdUrl);
         $info = [
           'name'=>env('app.name')
         ];
         View::assign('info', $info);
-
         return View::fetch();
     }
 
 
-    // 下载app 义礼德特
+    /**
+     * 下载app 义礼德特
+     * @param Request $request
+     * @return string
+     */
     public function downappyldt1 (Request $request)
     {
+        $config = SystemConfigService::make()->getConfigByNames(['site_android_cdn_url','site_ios_cdn_url'],1,'site');
+        $androidUrl = isset($config['site_android_cdn_url'])?$config['site_android_cdn_url'] : env('app.DOWN_ANDROID_URL_CDN');
+        $iosdUrl = isset($config['site_ios_cdn_url'])?$config['site_ios_cdn_url'] : env('app.DOWN_IOS_URL');
 
-
-        $a_url = env('app.DOWN_ANDROID_URL_CDN_TEST_YL');
-        $i_url = env('app.DOWN_IOS_URL');
-
-        $is_fair = false; // 是否是浏览器
+        $isFair = false; // 是否是浏览器
         if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') === !1) {
-            $is_fair = true;
+            $isFair = true;
         }
         View::assign([
-            'is_fair' => $is_fair,
+            'is_fair' => $isFair,
             'k' => $request->param('k', ''),
             'v' => $request->param('v', ''),
         ]);
 
-        View::assign('aurl', $a_url);
-        View::assign('iurl', $i_url);
-
+        View::assign('aurl', $androidUrl);
+        View::assign('iurl', $iosdUrl);
         return View::fetch();
     }
 
-    // 下载app yijiahui
+    /**
+     * 下载app yijiahui
+     * @param Request $request
+     * @return string
+     */
     public function downappyjh (Request $request)
     {
-//        // 这是测试 上线要干掉
-//            echo '网站正在升级中';
-//            die();
-
-
         $a_url = 'http://yijia.meikangjw.com/upload/yjhv1.0.apk';
         $i_url = 'https://lumayun-1305480448.file.myqcloud.com/efvsgp';
 

+ 9 - 18
app/api/controller/h5/User.php

@@ -20,7 +20,7 @@ class User
     {
         $this->service = $services;
     }
-    
+
     // 隐私政策
     public function privateInfo (Request $request)
     {
@@ -83,14 +83,14 @@ class User
 
     // 关于我们
     public function aboutUs (Request $request)
-     {
-         $id = $request->param('id/d', '');
-         $m_article = new SystemArticleModel();
-         $row = $m_article->where(['type' => 5])->findOrEmpty();
-         empty($row) && abort(403, '页面异常');
-         View::assign('row', $row);
-         return View::fetch();
-     }
+    {
+        $id = $request->param('id/d', '');
+        $m_article = new SystemArticleModel();
+        $row = $m_article->where(['type' => 5])->findOrEmpty();
+        empty($row) && abort(403, '页面异常');
+        View::assign('row', $row);
+        return View::fetch();
+    }
 
     /**
      * h5注册
@@ -99,9 +99,6 @@ class User
      */
     public function registerH5 (Request $request)
     {
-        // 这是测试 上线要干掉
-//        echo '网站正在更新';
-//        die();
         if ($request->isPost()) {
             $data = $request->post();
             try {
@@ -137,10 +134,6 @@ class User
 
         $code = $request->param('code');
         if ($code) {
-//            $code = decode($code);
-//            7H+6DCDrGMtrESqhogM
-//            $code = cryption($code, 'D', 'zy02022');
-//            return $code;
             !$code && abort(40003, '页面错误');
             $is_px = false;
             $invite = Db::name('user')->where('code', $code)->field('code,id')->find();
@@ -222,8 +215,6 @@ class User
      * @return string
      */
     public function aboutboxurl(Request $request){
-
-//        $id = $request->param('id/d', '');
         $m_article = new SystemArticleModel();
         $row = $m_article->where(['type' => 7])->findOrEmpty();
         empty($row) && abort(403, '页面异常');

+ 12 - 5
app/api/controller/v1/Box.php

@@ -161,7 +161,8 @@ class Box
     {
         $boxType = $request->post('box_type',0);
         $pageSize = $request->post('limit',10);
-        return api_succ_return(['msg' => '成功', 'data' => ShopGoodsService::make()->getBoxGoodsListByType($boxType,$pageSize)]);
+        $result = ShopGoodsService::make()->getBoxGoodsListByType($boxType,$pageSize);
+        return api_succ_return(['msg' => '成功', 'data' => isset($result['data'])? $result['data'] : []]);
     }
 
     /**
@@ -174,7 +175,8 @@ class Box
     {
         $boxType = [30,40];
         $pageSize = $request->post('limit',10);
-        return api_succ_return(['msg' => '成功', 'data' => ShopGoodsService::make()->getBoxGoodsListByType($boxType,$pageSize)]);
+        $result = ShopGoodsService::make()->getBoxGoodsListByType($boxType,$pageSize);
+        return api_succ_return(['msg' => '成功', 'data' => isset($result['data'])? $result['data'] : []]);
 
     }
 
@@ -207,10 +209,15 @@ class Box
         try{
             $dateType = $request->post('date_type', 1);
             $pageSize = $request->post('limit',10);
+            $post = $request->post();
             if($dateType==1){
-                return api_succ_return(['msg' => '获取今日数据成功', 'data' => BoxHandleService::make()->getBoxListByUser($request->uid,$request->post(),$pageSize)]);
+                $post['time'] = date('Y-m-d');
+                return api_succ_return(['msg' => '获取今日数据成功', 'data' => BoxHandleService::make()->getBoxListByUser($request->uid, $post,$pageSize)]);
             }else{
-                return api_succ_return(['msg' => '获取历史数据成功', 'data' => BoxHandleService::make()->getHistoryBoxList($request->uid,$request->post(),$pageSize)]);
+                $post['time1'] = date('Y-m-d');
+                $list = BoxHandleService::make()->getBoxListByUser($request->uid,$post,$pageSize);
+//                $list = BoxHandleService::make()->getHistoryBoxList($request->uid,$post,$pageSize);
+                return api_succ_return(['msg' => '获取历史数据成功1', 'data' => $list]);
             }
         } catch (\Exception $exception){
             return api_error_return('获取失败:'.$exception->getMessage());
@@ -271,7 +278,7 @@ class Box
     {
         $action = $request->post('action');
         $cacheKey = "caches:box:rebuy:user_{$request->uid}_{$action}";
-        if (RedisCache::get($cacheKey)) {
+        if (RedisCache::get($cacheKey) && $action != 'apply') {
             return api_error_return('请不要频繁操作,稍后再尝试');
         }
 

+ 97 - 57
app/api/controller/v1/Pay.php

@@ -9,6 +9,7 @@ use app\common\model\ShopGoodsModel;
 use app\common\model\ShopOrderGoodsModel as OrderGoods;
 use app\common\model\ShopOrderModel;
 use app\common\model\UserModel;
+use app\common\service\PayConfigService;
 use app\common\service\PaymentService;
 use app\common\service\SystemConfigService;
 use app\common\service\UserBankSignService;
@@ -39,58 +40,14 @@ class Pay
      */
     public function payconfig(Request $request)
     {
-        $setting = [];
-        $appresource = $request->post('app_sources', '');
-        $order_type = $request->post('order_type');
-        if (empty($order_type)) {
+        $paySource = $request->post('app_sources', '');
+        $orderType = $request->post('order_type');
+        if (empty($orderType)) {
             return api_error_return('参数错误');
         }
 
-
-        // 石区支付宝支付
-        array_push($setting, ['is_open' => 1, 'channel' => 22, 'title' => '支付宝支付', 'icon' => getWebUrl() . '/static/img/payconfig/ic_zhifubao.png']);
-
-        // 商城购买
-        if ($order_type == 4) {
-
-
-            if ($appresource == 'android') {
-
-                // 石学长 银联支付
-                array_push($setting, ['is_open' => 1, 'channel' => 15, 'title' => '银联(协议绑卡)', 'icon' => getWebUrl() . '/static/img/payconfig/ic_yinlian_pay.png']);
-
-
-            }
-
-            if ($appresource == 'ios') {
-                // 石学长 银联支付
-                array_push($setting, ['is_open' => 1, 'channel' => 15, 'title' => '银联', 'icon' => getWebUrl() . '/static/img/payconfig/ic_yinlian_pay.png']);
-
-            }
-
-        }
-
-
-        // 购买服务商
-        if ($order_type == 6) {
-
-            if ($appresource == 'android') {
-
-                // 石学长 银联支付
-                array_push($setting, ['is_open' => 1, 'channel' => 15, 'title' => '银联(协议绑卡)', 'icon' => getWebUrl() . '/static/img/payconfig/ic_yinlian_pay.png']);
-
-            }
-
-            if ($appresource == 'ios') {
-
-                // 石学长 银联支付
-                array_push($setting, ['is_open' => 1, 'channel' => 15, 'title' => '银联(协议绑卡)', 'icon' => getWebUrl() . '/static/img/payconfig/ic_yinlian_pay.png']);
-
-            }
-
-        }
-
-        return api_succ_return(['msg' => '成功', 'data' => ['setting' => $setting]]);
+        $channelList = PayConfigService::make()->getChannelList($orderType, $paySource);
+        return api_succ_return(['msg' => '成功', 'data' => ['setting' => array_values($channelList)]]);
     }
 
     /**
@@ -141,6 +98,7 @@ class Pay
         }
 
         // 加锁
+        $result = false;
         RedisCache::setnx($cacheKeyLock, 1, rand(2, 3));
         try {
 
@@ -153,12 +111,17 @@ class Pay
                 }
             }
 
-            if (!in_array($channel, [14, 15, 20, 22])) {
-                throw new Exception('支付类型错误');
+            $channelList = PayConfigService::make()->getChannelList($orderType, $app_sources);
+            if(empty($channelList)){
+                throw new Exception('支付渠道暂未开放,请先配置');
             }
 
-            if ($post['order_type'] == 4) {
+            $channels = $channelList? array_keys($channelList) : [15, 22, 66];
+            if (!in_array($channel, $channels)) {
+                throw new Exception('支付类型错误或未开放');
+            }
 
+            if ($post['order_type'] == 4) {
                 if (empty($post['order_id'])) {
                     throw new Exception('参数错误');
                 }
@@ -263,15 +226,23 @@ class Pay
                         $result = $pay->getYsfPayInfoTY($request->uid, $request->data);
                     }
                     break;
+                case 66:
+                    // 电科云闪付
+                    {
+                        $pay = new ThirdPayServices();
+                        $result = $pay->getPayInfoDiankeYsf($request->uid, $request->data);
+                    }
+                    break;
             }
 
         } catch (Exception $e) {
             RedisCache::clear($cacheKeyLock);
+            RedisCache::set("caches:payment:dkysf:otn_{$orderSn}:fail", ['msg'=>$e->getMessage(),'trace'=>$e->getTrace()], 7200);
             return api_error_return($e->getMessage());
         }
 
         RedisCache::keyDel("caches:paymentCall:u{$request->uid}_ot{$orderType}*");
-        return $result;
+        return $result? $result : api_error_return('支付请求错误或未开放,请联系客服');
 
     }
 
@@ -514,10 +485,10 @@ class Pay
         $amount = isset($params['amount'])? floatval($params['amount']) : 0;
         $paySign = isset($params['sign'])? trim($params['sign']) : '';
 
-        if(empty($paySign)){
-            unset($params['sign']);
-            return $service->diankesign($params);
-        }
+//        if(empty($paySign)){
+//            unset($params['sign']);
+//            return $service->diankesign($params);
+//        }
 
         // 加锁
         $key = $outTradeNo? $outTradeNo : date('YmdHis');
@@ -564,6 +535,75 @@ class Pay
         return 'fail';
     }
 
+    /**
+     * 电科支付回调处理
+     * @param Request $request
+     * @return string
+     */
+    public function thirdPayDkysfPayBack(Request $request)
+    {
+        $params = $request->param();
+        $service = new ThirdPayServices();
+        $date = date('Y-m-d H:i:s');
+        $outTradeNo = isset($params['orderId'])? trim($params['orderId']) : '';
+        $isPay = isset($params['pay'])? trim($params['pay']) : '';
+        $amount = isset($params['amount'])? floatval($params['amount']) : 0;
+        $paySign = isset($params['sign'])? trim($params['sign']) : '';
+
+        if(empty($paySign)){
+            unset($params['sign']);
+            return $service->makeSign($params);
+        }
+
+        // 加锁
+        $key = $outTradeNo? $outTradeNo : date('YmdHis');
+        $cacheKeyLock = "caches:payNotify:dkysf:locks:otn_{$key}";
+        $cacheKey = "caches:payNotify:dkysf:otn_{$key}:";
+        if(RedisCache::get($cacheKeyLock)){
+            return 'Frequent submission';
+        }
+
+        // 回调处理
+        RedisCache::setnx($cacheKeyLock, 1, rand(2,3));
+        RedisCache::set($cacheKey.'callback', ['params'=> $params,'date'=> $date], 7200);
+        if ($outTradeNo && $amount && $isPay == 'true') {
+            $payConfig = PayConfigService::make()->getInfoByChannel(66, 1);
+            $signKey = isset($payConfig['sign_key'])? $payConfig['sign_key'] : '';
+            if(empty($payConfig) || empty($signKey)){
+                return 'Payment config error';
+            }
+
+            // 校验签名
+            if ($paySign) {
+                $signData = $params;
+                unset($signData['sign']);
+                $sign = $service->makeSign($signData, $signKey);
+                if ($sign == $paySign) {
+                    Db::startTrans();
+                    try {
+                        PaymentService::make()->payBack($params['orderId'], $params['amount'], 66, json_encode($params));
+                        Db::commit();
+                        return 'success';
+                    } catch (\Exception $e) {
+                        Db::rollback();
+                        $error = [
+                            'msg'=> $e->getMessage(),
+                            'trace'=> $e->getTrace(),
+                        ];
+                        RedisCache::set($cacheKey.'fail', ['params'=> $params,'error'=> $error,'date'=> $date], 7200);
+                        RedisCache::clear($cacheKeyLock);
+                    }
+                } else {
+                    RedisCache::set($cacheKey.'error', ['params'=> $params,'error'=>'签名错误','date'=> $date], 7200);
+                }
+            }else{
+                RedisCache::set($cacheKey.'error', ['params'=> $params,'error'=>'缺少签名参数','date'=> $date], 7200);
+            }
+
+        }
+
+        return 'fail';
+    }
 
     /**
      * 支付宝支付回调

+ 18 - 17
app/api/controller/v1/User.php

@@ -116,7 +116,6 @@ class User
 
     }
 
-
     /**
      * 退出登录
      * @param Request $request
@@ -252,7 +251,7 @@ class User
      * @param MoneyLogModel $model
      * @return \think\Response
      */
-    public function moneyLog (Request $request, MoneyLogModel $model)
+    public function moneyLog(Request $request, MoneyLogModel $model)
     {
         try {
             return api_succ_return(['msg'=>'成功', 'data'=>$model->getLog($request)]);
@@ -262,6 +261,23 @@ class User
     }
 
     /**
+     * 利润结算记录
+     * @param Request $request
+     * @return \think\Response
+     */
+    public function incomeMoneyLog(Request $request,MoneyLogModel $model){
+        try {
+            $pageSize = $request->post('limit', 10);
+            $post = $request->post();
+            $post['uid'] = $request->uid;
+//            return api_succ_return(['msg'=>'成功', 'data'=>$model->getLog($request, 8)]);
+            return api_succ_return(['msg'=>'成功', 'data'=>UserUnmoneyService::make()->getList($post, $pageSize)]);
+        } catch (\Exception $e) {
+            return api_error_return('失败'.$e->getMessage());
+        }
+    }
+
+    /**
      * 积分记录
      * @param Request $request
      * @param ScoreLogModel $model
@@ -846,21 +862,6 @@ class User
         }
     }
 
-    /**
-     * 利润结算记录
-     * @param Request $request
-     * @return \think\Response
-     */
-    public function incomeMoneyLog(Request $request){
-        try {
-            $pageSize = $request->post('limit', 10);
-            $post = $request->post();
-            $post['uid'] = $request->uid;
-            return api_succ_return(['msg'=>'成功', 'data'=>UserUnmoneyService::make()->getList($post, $pageSize)]);
-        } catch (\Exception $e) {
-            return api_error_return('失败'.$e->getMessage());
-        }
-    }
 
     /**
      * 利润结算到余额

+ 127 - 1
app/api/services/ThirdPayServices.php

@@ -14,6 +14,7 @@ use app\common\model\ShopOrderModel as Order;
 use app\common\model\UserBankSignModel;
 use app\common\model\UserModel;
 use app\common\model\WithDrawLogModel;
+use app\common\service\PayConfigService;
 use app\common\service\PaymentService;
 use app\common\service\UserBankSignService;
 use app\common\service\UserService;
@@ -23,6 +24,19 @@ use utils\RedisCache;
 
 class ThirdPayServices extends BasePayServices
 {
+    protected $dkError = [
+        '40001'=>'请求参数有误(缺少或者格式有误)',
+        '40002'=>'尚未登录/回话超时',
+        '40500'=>'处理扫码付错误',
+        '40510'=>'不支持的通道',
+        '40511'=>'通道已失效',
+        '40513'=>'商户不合法',
+        '40520'=>'订单不存在',
+        '40521'=>'订单已存在',
+        '50001'=>'未授权',
+        '50002'=>'签名错误',
+    ];
+
 
     /**
      * 多乐宝支付宝支付
@@ -1457,6 +1471,8 @@ class ThirdPayServices extends BasePayServices
 
 
         $loData['result'] = $result;
+        $code = isset($result['code'])? $result['code'] : '';
+        $msg = isset($this->dkError[$code])? $this->dkError[$code] : '';
         RedisCache::set($cacheKey.'result', $loData, 2*86400);
         if ($payUrl) {
             $payment = [
@@ -1478,7 +1494,98 @@ class ThirdPayServices extends BasePayServices
             return api_succ_return(['msg' => '成功', 'data' => ['pay_url' => $payUrl]]);
 
         } else {
-            return api_error_return('支付错误,请联系客服');
+            return api_error_return($msg? '支付错误:'.$msg:'支付错误,请联系客服');
+        }
+    }
+
+    /**
+     * 电科云闪付
+     * @param $uid
+     * @param $params
+     * @return \think\Response
+     * @throws Exception
+     */
+    public function getPayInfoDiankeYsf($uid, $payData)
+    {
+        list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $payData);
+
+        // 接口地址
+        $payConfig = PayConfigService::make()->getInfoByChannel($pay_way, $order_type);
+        $apiUrl = isset($payConfig['api_url'])? trim($payConfig['api_url']) : '';
+        $apiUrl = $apiUrl? $apiUrl : 'http://1.14.197.47/proxy';
+        $appId = isset($payConfig['app_id'])? trim($payConfig['app_id']) : '';
+        $signKey = isset($payConfig['sign_key'])? trim($payConfig['sign_key']) : '';
+        if(empty($payConfig) || empty($appId) || empty($apiUrl) || empty($signKey)){
+            return api_error_return('支付配置错误,请先配置支付参数');
+        }
+
+        $date = date('Y-m-d H:i:s');
+        $out_trade_no = createdOrderSn();
+        $cacheKey = "caches:payment:dkysf:otn_{$out_trade_no}:{$uid}_{$remarks}_";
+        RedisCache::set($cacheKey.'payData', ['payData'=> $payData, 'date'=>$date], 2*86400);
+
+        // 测试金额
+        if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
+            $total_amount = floatval('0' . '.' . mt_rand(1, 2) . mt_rand(1, 9));
+        }
+
+        if ($total_amount > 15000) {
+            $loData = ['payData'=> $payData,'error'=>'大额不能使用支付宝支付', 'date'=>$date];
+            RedisCache::set($cacheKey.'error', $loData, 2*86400);
+            sr_throw('大额不能使用支付宝支付');
+        }
+
+        $params = [
+            'appId' => $appId,
+            'version' => '1.0',
+            'nonceStr' => nonce_str(15),
+            'orderId' => $out_trade_no,
+            'amount' => intval($total_amount * 100),
+            'payChannel' => 'WXP',
+            'goodsName' => $body? $body : '牛仔裤',
+            'goodsDesc' => $body? $body : '牛仔裤',
+            'clientIp' => get_client_ip(),
+            'asyncNotifyUrl' => env('PAYSQZ.PAYBACK_YSF_URL'),
+            'tradeType' => 'QRCODE'
+        ];
+
+        ksort($params);
+        $params['sign'] = $this->makeSign($params, $signKey);
+
+        // 提交确定支付请求接口
+        $payApiUrl = $apiUrl.'/pay/unifiedorder';
+        $loData = ['url'=>$payApiUrl,'payData'=> $payData,'payconfig'=>$payConfig,'params'=> $params, 'date'=>$date];
+        RedisCache::set($cacheKey.'request', $loData, 2*86400);
+        $result = curlPost($payApiUrl, $params);
+        $result = $result? json_decode($result, true) : [];
+        $payUrl = isset($result['data'])? $result['data'] : '';
+
+
+        $loData['result'] = $result;
+        $code = isset($result['code'])? $result['code'] : '';
+        $msg = isset($this->dkError[$code])? $this->dkError[$code] : '';
+        RedisCache::set($cacheKey.'result', $loData, 2*86400);
+        if ($payUrl) {
+            $payment = [
+                'total_fee' => $total_amount,
+                'trade_type' => $trade_type,
+                'body' => $body,
+                'state' => 7,
+                'out_trade_no' => $out_trade_no,
+                'pay_way' => $pay_way,
+                'remarks' => $remarks,
+                'order_type' => $order_type,
+                'uid' => $uid,
+                'voucher_img' => $voucher_img,
+                'out_trade_no1' => '',
+                'hy_token_id' => ''
+            ];
+            Db::name('payment')->insert($payment);
+
+            return api_succ_return(['msg' => '成功', 'data' => ['pay_url' => $payUrl]]);
+
+        } else {
+            return api_error_return($msg? '支付错误:'.$msg:'支付错误,请联系客服');
         }
     }
 
@@ -1621,6 +1728,25 @@ class ThirdPayServices extends BasePayServices
     }
 
     /**
+     * 公共支付签名
+     * @param $data
+     * @return string
+     */
+    public function makeSign($data, $signKey='')
+    {
+        ksort($data);
+        $signStr = "";
+        foreach ($data as $key => $val) {
+            $signStr .= $key . '=' . $val . '&';
+        }
+        $stringSignTemp = $signStr . 'key='.$signKey;
+        $signtemp = md5($stringSignTemp);
+
+        return strtoupper($signtemp);
+
+    }
+
+    /**
      * 签名
      * @param $data
      * @return string

+ 9 - 5
app/common/model/MoneyLogModel.php

@@ -39,8 +39,16 @@ class MoneyLogModel extends Model
         return compact('list', 'history');
     }
 
+    /**
+     * 团队奖金
+     * @param $param
+     * @return array
+     * @throws \think\db\exception\DbException
+     */
     public function getTeamMoneyLog($param){
         $type_conf = config('type.money');
+        $total = self::where('uid', $param->uid)
+            ->whereIn('type', [5,7])->sum('money');
         $list = self::where('uid', $param->uid)
             ->whereIn('type', [5,7])
             ->withAttr('type', function ($value, $data) use ($type_conf) {
@@ -49,10 +57,6 @@ class MoneyLogModel extends Model
             ->order('id', 'desc')
             ->paginate($param->data['limit'])
             ->toArray();
-//        $history = self::where([
-//            ['uid', '=', $param->uid],
-//            ['state', '=', 1]
-//        ])->sum('money');
-        return $list['data'];
+        return ['list'=>$list['data'],'total'=>$total,'count'=>$list['total']];
     }
 }

+ 27 - 7
app/common/service/BoxHandleService.php

@@ -75,6 +75,7 @@ class BoxHandleService
             unset($where['r.box_type']);
         }
 
+//        var_dump($where);
         $list = $this->model->alias('r')
                 ->where($where)
                 ->where(function($query) use($params){
@@ -83,8 +84,18 @@ class BoxHandleService
                         $query->where('r.h_sn','like',"%{$keyword}%");
                     }
                 })
-                ->where('r.open_time','<=',date('Y-m-d H:i:s'))
-                ->where('r.create_time','>=',date('Y-m-d'))
+                ->where(function($query){
+                    $query->where('r.open_time','<=',date('Y-m-d H:i:s'))->whereOr('r.open_time','null');
+                })
+                ->where(function($query) use($params){
+                    $time = isset($params['time'])? $params['time'] : '';
+                    $time1 = isset($params['time1'])? $params['time1'] : '';
+                    if($time){
+                        $query->where('r.create_time','>=', $time);
+                    }else if($time1){
+                        $query->where('r.create_time','<', $time1);
+                    }
+                })
                 ->field('r.*')
                 ->order('r.create_time desc,r.id desc')
                 ->paginate($pageSize)
@@ -139,6 +150,7 @@ class BoxHandleService
             unset($where['r.box_type']);
         }
 
+
         $list = BoxHandleAllModel::alias('r')
             ->where($where)
             ->where(function($query) use($params){
@@ -147,7 +159,9 @@ class BoxHandleService
                     $query->where('r.h_sn','like',"%{$keyword}%");
                 }
             })
-            ->where('r.open_time','<=',date('Y-m-d H:i:s'))
+            ->where(function($query){
+                $query->where('r.open_time','<=',date('Y-m-d H:i:s'))->whereOr('r.open_time','null');
+            })
             ->where('r.create_time','<',date('Y-m-d'))
             ->field('r.*')
             ->order('r.create_time desc,r.id desc')
@@ -182,9 +196,12 @@ class BoxHandleService
     public function getBoxCount($uid,$status,$dateType=1)
     {
         $counts = ['10'=>0,'20'=>0,'30'=>0,'40'=>0];
-        $model = $dateType == 1? new BoxHandleModel() : new BoxHandleAllModel();
+        $model = new BoxHandleModel();
+//        $model = $dateType == 1? new BoxHandleModel() : new BoxHandleAllModel();
         $datas = $model->where(['uid'=>$uid,'status'=>$status,'is_delete'=>2])
-            ->where('open_time','<=',date('Y-m-d H:i:s'))
+            ->where(function($query){
+                $query->where('open_time','<=',date('Y-m-d H:i:s'))->whereOr('open_time','null');
+            })
             ->where(function($query) use($dateType){
                 if($dateType == 1){
                     $query->where('create_time','>=',date('Y-m-d'));
@@ -230,7 +247,8 @@ class BoxHandleService
         if (!in_array($catchType, [1,2])){
             sr_throw('处理参数错误');
         }
-        $model = $catchType==1? new BoxHandleModel() : new BoxHandleAllModel();
+        $model = new BoxHandleModel();
+//        $model = $catchType==1? new BoxHandleModel() : new BoxHandleAllModel();
         $boxList = $model->whereIn('id', $ids)
             ->where(['uid'=>$uid,'status'=>1,'is_delete'=>2])
             ->field('id,h_sn,status,uid,rid,handle_type,goods_id,box_type,goods_price')
@@ -278,6 +296,7 @@ class BoxHandleService
                 'status'=>1,
                 'num'=>1,
                 'order_type'=>5,
+                'order_remark'=> '福袋:'.$val['h_sn'],
                 'order_source'=> '福袋单号:'.$val['h_sn'],
                 'supplier_name'=>$goodsInfo['supplier_name'],
                 'total_price'=>0,
@@ -372,7 +391,8 @@ class BoxHandleService
             sr_throw('处理参数错误');
         }
         $num = count($ids);
-        $model = $catchType==1? new BoxHandleModel() : new BoxHandleAllModel();
+        $model = new BoxHandleModel();
+//        $model = $catchType==1? new BoxHandleModel() : new BoxHandleAllModel();
         $boxList = $model->whereIn('id', $ids)
             ->where(['uid'=>$uid,'status'=>1,'is_delete'=>2])
             ->field('id,h_sn,status,uid,rid,handle_type,goods_id,box_type,goods_price')

+ 18 - 8
app/common/service/BoxRecordService.php

@@ -3,6 +3,7 @@
 namespace app\common\service;
 
 use app\admin\model\dao\BoxMidHandle;
+use app\common\model\BoxHandleAllModel;
 use app\common\model\BoxHandleModel;
 use app\common\model\BoxMidHandleModel;
 use app\common\model\BoxModel;
@@ -99,10 +100,11 @@ class BoxRecordService
             ->leftJoin('user u', 'u.id = r.uid')
             ->field(Db::raw('r.*,u.mobile,u.total_null_box,sum(r.num) as num,u.total_free,u.total_appoint_count,u.total_income,u.yesterday_money,u.box10 as ubox10,u.box20 as ubox20,u.box30 as ubox30,u.box40 as ubox40,u.path'))
             ->group('group_key')
+            ->order('r.create_time desc')
             ->order('r.qi_count desc')
             ->order('r.lun_count desc')
             ->order('r.num desc')
-            ->order('r.create_time desc')
+
             ->paginate($pageSize)
             ->each(function($item, $k){
                 $path = isset($item['path'])? $item['path'] : '';
@@ -187,7 +189,7 @@ class BoxRecordService
         }
 
         if ($boxCount > 20) {
-            sr_throw('最多可预约20个');
+            sr_throw('每次最多可预约20个');
         }
 
         // 如果预约数量小于5
@@ -196,8 +198,9 @@ class BoxRecordService
         }
 
         // 预约数量限制
-        if ($this->model->where(['uid' => $uid, 'status' => 1])->sum('num') > 100) {
-            sr_throw('每一场最多可预约100次');
+        $applyCount = $this->model->where(['uid' => $uid, 'status' => 1])->sum('num');
+        if ($applyCount + $boxCount> 100) {
+            sr_throw("每一场最多可预约100个,您已预约".($applyCount)."个");
         }
 
         $lun = 1;
@@ -509,7 +512,7 @@ class BoxRecordService
                     foreach ($boxArr as $bk => $bName) {
                         $goodsArr = isset($boxGoods[$bk]) ? $boxGoods[$bk] : [];
                         $awardNum = isset($val['box' . $bk]) ? intval($val['box' . $bk]) : 0;
-                        $time = sr_getcurtime(time() + ($bk / 10));
+                        $time = sr_getcurtime(strtotime($openTime) + ($bk / 10));
 
                         // 有中奖
                         if ($awardNum > 0) {
@@ -535,7 +538,7 @@ class BoxRecordService
                                     'rid' => $rid,
                                     'status' => 2,
                                     'goods_id' => $goodsId,
-                                    'create_time' => $time,
+                                    'create_time' => $time<$openTime?$openTime:$time,
                                     'box_settle_time' => $openTime,
                                     'box_type' => $bk,
                                     'goods_price' => isset($goods['price']) ? $goods['price'] : 0,
@@ -550,7 +553,7 @@ class BoxRecordService
                                     'rid' => $rid,
                                     'handle_type' => 0,
                                     'goods_id' => $goodsId,
-                                    'create_time' => $time,
+                                    'create_time' => $time<$openTime?$openTime:$time,
                                     'open_time' => $openTime,
                                     'box_type' => $bk,
                                     'goods_price' => isset($goods['price']) ? $goods['price'] : 0
@@ -655,13 +658,20 @@ class BoxRecordService
                 return "开袋失败:写入福袋处理数据错误";
             }
 
-            // 插入中奖盒子数据
+            // 插入备份中奖盒子数据
             if ($boxOpenArr && !BoxHandleModel::insertAll($boxOpenArr)) {
                 Db::rollback();
                 RedisCache::set($cacheKey . "error", ['ids' => $ids, 'count' => count($boxMidList),'scoreNum'=>$tempScorePayNum, 'award' => count($boxOpenArr), 'date' => $date, 'msg' => "开袋失败:写入福袋中奖数据错误"], $cacheTime);
                 return "开袋失败:写入福袋中奖数据错误";
             }
 
+            // 插入中奖盒子数据
+            if ($boxOpenArr && !BoxHandleAllModel::insertAll($boxOpenArr)) {
+                Db::rollback();
+                RedisCache::set($cacheKey . "errora", ['ids' => $ids, 'count' => count($boxMidList),'scoreNum'=>$tempScorePayNum, 'award' => count($boxOpenArr), 'date' => $date, 'msg' => "开袋失败:写入备份福袋中奖数据错误"], $cacheTime);
+                return "开袋失败:写入福袋中奖数据错误";
+            }
+
             Db::commit();
 
             RedisCache::clear($cacheKey . 'lock');

+ 36 - 3
app/common/service/PayConfigService.php

@@ -40,15 +40,15 @@ class PayConfigService
      * @param bool $cache
      * @return array|mixed
      */
-    public function getInfoByChannel($channel, $field='', $cache=true)
+    public function getInfoByChannel($channel, $scene=1, $paySource=1, $cache=true)
     {
-        $cacheKey = "caches:temp:payConfig:channel_{$channel}".($field? '_'.md5($field):'');
+        $cacheKey = "caches:temp:payConfig:info:c_{$channel}_{$scene}_{$paySource}";
         $data = RedisCache::get($cacheKey);
         if($data && $cache){
             return $data;
         }
 
-        $field = $field? $field : 'app_id,private_key,public_key,app_cert_path,pay_root_cert,pay_cert_path,mchid';
+        $field = 'app_id,title,pay_code,sign_key,scene,pay_source,api_url,private_key,public_key,app_cert_path,pay_root_cert,pay_cert_path,mchid';
         $data = $this->model->where(['channel'=> $channel,'status'=>1])->field($field)->findOrEmpty();
         $data = $data? $data->toArray() : [];
         if($data && $cache){
@@ -57,4 +57,37 @@ class PayConfigService
 
         return $data;
     }
+
+    /**
+     * 获取开启的支付渠道配置
+     * @param int $scene 支付场景:1-所有,4-商城,6-服务商
+     * @param int $paySource 支付来源:1-所有,2-安卓,3-苹果
+     * @param bool $cache
+     * @return array|mixed
+     */
+    public function getChannelList($scene=1, $paySource=1, $cache=true)
+    {
+        $cacheKey = "caches:temp:payConfig:channelList:s_{$scene}_{$paySource}";
+        $data = RedisCache::get($cacheKey);
+        if($data && $cache){
+            return $data;
+        }
+        $where = ['status'=>1];
+        if($scene>0){
+            $where['scene'] = $scene;
+        }
+        if($paySource>0){
+            $where['pay_source'] = $paySource;
+        }
+        $field = 'app_id,title,pay_code,sign_key,scene,pay_source,api_url,private_key,icon,public_key,app_cert_path,pay_root_cert,pay_cert_path,mchid';
+        $data = $this->model->where($where)->withAttr('icon',function($value){
+            return getWebUrl().$value;
+        })->order('sort asc,id asc')->column($field,'channel');
+        if($data && $cache){
+
+            RedisCache::set($cacheKey, $data, 7200);
+        }
+
+        return $data;
+    }
 }

+ 2 - 1
app/common/service/PaymentService.php

@@ -34,7 +34,8 @@ class PaymentService
         19=>'usdtPay',
         20=>'yswkPay',
         22=>'dkpay',
-        56=>'ysftyPay'
+        56=>'ysftyPay',
+        66=>'dkysf',
     ];
     protected $model = null;
 

+ 2 - 0
config/type.php

@@ -19,6 +19,7 @@ return [
       ],
     // 余额
     'money'=>[
+        0=>'其他',
         1=>'预约福袋',
         2=>'回收商品',
         3=>'预约福袋空盒退回',
@@ -39,6 +40,7 @@ return [
     ],
     // 积分
     'score'=>[
+        0=>'其他',
         1=>'预约福袋',
         2=>'预约福袋空盒退回',
         3=>'买商品送积分',

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
public/h5/index.html


BIN
public/h5/static/images/common/check1.png


BIN
public/h5/static/images/common/checked1.png


BIN
public/h5/static/img/bg_chengwei_fuwushang@2x.f1c41f7f.png


BIN
public/h5/static/img/bg_denglu_dise@2x.10ae4faf.png


BIN
public/h5/static/img/bg_fudai_chaichu@2x.e20beca8.png


BIN
public/h5/static/img/bg_fudai_dise_one@2x.38bb749c.png


BIN
public/h5/static/img/bg_home_bottom.cef3191f.png


BIN
public/h5/static/img/bg_home_notice.000aa8aa.png


BIN
public/h5/static/img/bg_hudai_texiao@2x.bd406325.png


BIN
public/h5/static/img/bg_me_cenrer@2x.781e24c2.png


BIN
public/h5/static/img/bg_me_haoyou_ds@2x.a3125711.png


BIN
public/h5/static/img/bg_shengji@2x.30267671.png


BIN
public/h5/static/img/bg_yushou@2x.da1f0f03.png


BIN
public/h5/static/img/bt_me_fucang@2x.cc8e6296.png


BIN
public/h5/static/img/bt_me_yuyue@2x.866b6c73.png


BIN
public/h5/static/img/bt_xinshou_jiaochen@2x.3204d4ed.png


BIN
public/h5/static/img/ic_chaidai_fd@2x.1a3ed457.png


BIN
public/h5/static/img/ic_duobaofudai_d@2x.3953cc90.png


BIN
public/h5/static/img/ic_fahuo_diz.f83cb391.png


BIN
public/h5/static/img/ic_huishouka_fd@2x.8a3e0046.png


BIN
public/h5/static/img/ic_kefu_fd@2x.709f493c.png


BIN
public/h5/static/img/ic_lianxi_kh@2x.7a9eaec5.png


BIN
public/h5/static/img/ic_paopao_two@2x.bdccc9ca.png


BIN
public/h5/static/img/ic_time_fd@2x.eea1ebc0.png


BIN
public/h5/static/img/ic_wenxintishi@2x.5a5ab06c.png


BIN
public/h5/static/img/ic_xinshou_zhiyin@2x.53075e16.png


BIN
public/h5/static/img/subscribe.372ade69.gif


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
public/h5/static/js/index.a22b3d45.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pages-index-index.51eb4d5f.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pages-index-index.a9515edd.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pages-login-login.3530f383.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pages-login-login.f438e24f.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pages-login-register.2c865ac7.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pages-login-register.39b21002.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pages-me-me.9490a009.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pages-me-me.a84ece74.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pages-sweepstakes-sweepstakes.ab3c8f3e.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pages-sweepstakes-sweepstakes.e5b58d41.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pages-warehouse-warehouse.9b62782d.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pages-warehouse-warehouse.9eccef5b.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesGoods-goodsDetail-goodsDetail.7b32a3a2.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesGoods-goodsDetail-goodsDetail.f800edc5.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesGoods-order-orderSubmit.587c977b.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesGoods-order-orderSubmit.d0d6f217.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesGoods-sweepstakes-sweepstakesGoods.2f0fa0c4.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesGoods-sweepstakes-sweepstakesGoods.a4a075d2.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesUser-asset-balance.48ead5b8.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesUser-asset-balance.c0722d3d.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesUser-asset-withdraw.daa3c516.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesUser-asset-withdraw.e453a298.js


Разница между файлами не показана из-за своего большого размера
+ 2 - 2
public/h5/static/js/pagesUser-chat-chat.4f71af2b.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesUser-message-notice.5057d2dd.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesUser-message-notice.af6228da.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesUser-setting-about.0c3b2b2f.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesUser-setting-about.237efffd.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/h5/static/js/pagesUser-team-team.02e25bc1.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/h5/static/js/pagesUser-team-team.71bc607f.js


+ 0 - 0
public/static/admin/images/cate_all.png


+ 0 - 0
public/static/admin/images/chajiu.png


+ 0 - 0
public/static/admin/images/fushi.png


+ 0 - 0
public/static/admin/images/jiadian.png


+ 0 - 0
public/static/admin/images/jinping.jpg


+ 0 - 0
public/static/admin/images/lingshi.png


+ 0 - 0
public/static/admin/images/loginbg1.jpeg


+ 0 - 0
public/static/admin/images/loginbg12.png


+ 0 - 0
public/static/admin/images/shoushi.png


+ 0 - 0
public/static/admin/images/shuma.png


+ 0 - 0
public/static/admin/images/tehui.jpg


+ 0 - 0
public/static/admin/images/tiyan.jpg


+ 0 - 0
public/static/admin/images/xiangbao.png


+ 0 - 0
public/static/admin/images/xinshou.jpg


+ 0 - 0
public/static/admin/images/yushi.png


+ 0 - 0
public/static/admin/images/zhongbiao.png


+ 0 - 0
public/static/admin/js/box/appoint_list.js


+ 0 - 0
public/static/admin/js/box/box.js


+ 0 - 0
public/static/admin/js/box/handle_box_action.js


+ 0 - 0
public/static/admin/js/box/matching_box.js


+ 2 - 5
public/static/admin/js/box/open_box_action.js

@@ -135,12 +135,9 @@ define(["jquery", "easy-admin"], function ($, ea) {
                             id: ids
                         },
                     }, function (res) {
-                        layer.confirm(msg, {title: '开奖结果', btn: ['确认'], time: 20000}, function () {
+                       ea.msg.alert(res.msg, function () {
                             document.reload();
-                        })
-                       // ea.msg.confirm(res.msg, function () {
-                       //      document.reload();
-                       //  },20000);
+                        },20000);
                     });
                 });
                 return false;

+ 0 - 0
public/static/admin/js/user/recharge.js


+ 1 - 0
public/static/admin/js/user/user.js

@@ -46,6 +46,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
                     },
 
                     {field: 'pid', width: 100, title: '上级ID'},
+                    {field: 'code', width: 120, title: '邀请码'},
                     {field: 'is_px', width: 80, title: '来源', search: 'select', selectList: {0: '邀请码', 1: '排线码'}},
                     {field: 'is_auth', width: 100, title: '是否实名', search: 'select', selectList: {0: '未实名', 1: '已实名'}},
                     // {field: 'coin', width: 80, title: 'T币', searchOp: 'range'},

+ 0 - 0
public/static/api/image/user/ic_dl_logo@3x.png


Некоторые файлы не были показаны из-за большого количества измененных файлов