rabin 3 месяцев назад
Родитель
Сommit
5d26942380
100 измененных файлов с 4896 добавлено и 4798 удалено
  1. 41 41
      src/cate/api/Icon.php
  2. 28 28
      src/cate/lib/Info.php
  3. 36 42
      src/cate/manage/core.php
  4. 45 58
      src/cate/manage/level_1.php
  5. 52 66
      src/cate/manage/level_2.php
  6. 61 78
      src/cate/manage/level_3.php
  7. 23 29
      src/cate/table/icon.php
  8. 34 42
      src/cate/table/level_1.php
  9. 38 47
      src/cate/table/level_2.php
  10. 45 56
      src/cate/table/level_3.php
  11. 17 12
      src/place/act/lib/Core.php
  12. 21 26
      src/place/act/table/collect.php
  13. 21 26
      src/place/act/table/like.php
  14. 33 40
      src/place/act/table/review.php
  15. 97 91
      src/place/boot.php
  16. 42 50
      src/place/channel/table/seller.php
  17. 38 46
      src/place/channel/table/supplier.php
  18. 43 7
      src/place/interface/api/Address.php
  19. 0 52
      src/place/interface/api/Agent.php
  20. 1 1
      src/place/interface/api/Collect.php
  21. 11 6
      src/place/interface/api/Coupon.php
  22. 63 15
      src/place/interface/api/Main.php
  23. 29 44
      src/place/interface/api/Role.php
  24. 0 52
      src/place/interface/api/Saler.php
  25. 39 0
      src/place/interface/api/Score.php
  26. 29 23
      src/place/interface/api/Source.php
  27. 1 1
      src/place/interface/api/Tool.php
  28. 59 22
      src/place/interface/api/User.php
  29. 0 45
      src/place/interface/api/Vip.php
  30. 0 9
      src/place/interface/api/Wallet.php
  31. 194 159
      src/place/order/lib/Pay.php
  32. 45 0
      src/place/order/lib/Role/Log.php
  33. 80 70
      src/place/order/lib/Role/Pay.php
  34. 3 3
      src/place/order/lib/Source/Cart.php
  35. 104 104
      src/place/order/lib/Source/Express.php
  36. 1 1
      src/place/order/lib/Source/Log.php
  37. 262 276
      src/place/order/lib/Source/Order.php
  38. 115 112
      src/place/order/lib/Source/Pay.php
  39. 142 142
      src/place/order/lib/Source/Refund.php
  40. 5 6
      src/place/order/lib/Source/User.php
  41. 25 25
      src/place/order/lib/Source/Virtual.php
  42. 44 44
      src/place/order/manage/Lib/Source/Address.php
  43. 322 364
      src/place/order/manage/Lib/Source/Order.php
  44. 58 67
      src/place/order/manage/core.php
  45. 37 45
      src/place/order/manage/role.php
  46. 50 60
      src/place/order/manage/source.php
  47. 40 48
      src/place/order/manage/source_address.php
  48. 23 29
      src/place/order/manage/source_express.php
  49. 33 42
      src/place/order/manage/source_refund.php
  50. 26 32
      src/place/order/manage/source_refund_audit.php
  51. 17 22
      src/place/order/manage/source_refund_detail.php
  52. 20 25
      src/place/order/manage/source_virtual.php
  53. 87 92
      src/place/order/table/role.php
  54. 61 0
      src/place/order/table/role_detail.php
  55. 33 0
      src/place/order/table/role_log.php
  56. 145 153
      src/place/order/table/source.php
  57. 41 50
      src/place/order/table/source_cart.php
  58. 65 79
      src/place/order/table/source_detail.php
  59. 22 27
      src/place/order/table/source_express.php
  60. 33 40
      src/place/order/table/source_log.php
  61. 90 107
      src/place/order/table/source_refund.php
  62. 31 38
      src/place/order/table/source_refund_detail.php
  63. 27 33
      src/place/order/table/source_refund_express.php
  64. 16 20
      src/place/order/table/source_virtual.php
  65. 39 48
      src/place/order/table/user_source.php
  66. 58 71
      src/place/order/table/user_source_log.php
  67. 179 0
      src/place/role/lib/Info.php
  68. 99 0
      src/place/role/lib/User.php
  69. 22 22
      src/place/role/manage/Lib/Api.php
  70. 1 1
      src/place/role/manage/Lib/Data.php
  71. 27 32
      src/place/role/manage/core.php
  72. 53 65
      src/place/role/manage/info.php
  73. 74 103
      src/place/role/manage/level.php
  74. 37 36
      src/place/role/manage/profit_buy.php
  75. 42 46
      src/place/role/manage/profit_partner.php
  76. 30 37
      src/place/role/manage/profit_sale.php
  77. 40 44
      src/place/role/table/info.php
  78. 58 76
      src/place/role/table/level.php
  79. 52 53
      src/place/role/table/profit_buy.php
  80. 67 69
      src/place/role/table/profit_partner.php
  81. 48 54
      src/place/role/table/profit_sale.php
  82. 42 46
      src/place/role/table/user.php
  83. 10 10
      src/place/score/lib/Action.php
  84. 53 0
      src/place/score/lib/Info.php
  85. 150 163
      src/place/score/lib/Log.php
  86. 8 2
      src/place/score/lib/Rebate.php
  87. 25 0
      src/place/score/lib/User.php
  88. 18 0
      src/place/score/manage/Lib/Action.php
  89. 22 28
      src/place/score/manage/convert.php
  90. 47 48
      src/place/score/manage/core.php
  91. 84 78
      src/place/score/manage/info.php
  92. 23 29
      src/place/score/manage/rebate.php
  93. 45 0
      src/place/score/manage/recharge.php
  94. 71 90
      src/place/score/manage/rule.php
  95. 36 46
      src/place/score/manage/user.php
  96. 28 33
      src/place/score/manage/user_log.php
  97. 20 12
      src/place/score/table/action.php
  98. 10 13
      src/place/score/table/action_cate.php
  99. 0 32
      src/place/score/table/action_log.php
  100. 34 41
      src/place/score/table/convert.php

+ 41 - 41
src/cate/api/Icon.php

@@ -1,42 +1,42 @@
-<?php namespace Cate\Api;
-use Dever;
-class Icon
-{
-    public function getList()
-    {
-        $id = Dever::input('id');
-        $name = Dever::input('name');
-        $where = array();
-        if ($name && $name != '{name}') {
-            $where['search_name'] = array('like', $name);
-        }
-        $list = array();
-        if ($id) {
-            $info = Dever::db('icon', 'cate')->find($id);
-            if ($info) {
-                $this->getSvg($info);
-                $info['class'] = 'show-selector-active';
-                $list[] = $info;
-            }
-        }
-        $set['num'] = 12;
-        $data = Dever::db('icon', 'cate')->select($where, $set);
-        foreach ($data as $k => $v) {
-            if ($id && $v['id'] == $id) {
-                continue;
-            }
-            $this->getSvg($v);
-            $list[] = $v;
-        }
-        return array('list' => $list, 'total' => Dever::page('total'));
-    }
-
-    private function getSvg(&$v)
-    {
-        $v['type'] = 'svg';
-        $pattern = '/(width|height): [^;]+;/';
-        $replacement = 'width: 30px; height: 30px;';
-        $v['svg'] = preg_replace($pattern, $replacement, $v['svg']);
-        $v['class'] = '';
-    }
+<?php namespace Cate\Api;
+use Dever;
+class Icon
+{
+    public function getList()
+    {
+        $id = Dever::input('id');
+        $name = Dever::input('name');
+        $where = [];
+        if ($name && $name != '{name}') {
+            $where['search_name'] = ['like', $name];
+        }
+        $list = [];
+        if ($id) {
+            $info = Dever::db('icon', 'cate')->find($id);
+            if ($info) {
+                $this->getSvg($info);
+                $info['class'] = 'show-selector-active';
+                $list[] = $info;
+            }
+        }
+        $set['num'] = 12;
+        $data = Dever::db('icon', 'cate')->select($where, $set);
+        foreach ($data as $k => $v) {
+            if ($id && $v['id'] == $id) {
+                continue;
+            }
+            $this->getSvg($v);
+            $list[] = $v;
+        }
+        return ['list' => $list, 'total' => Dever::page('total')];
+    }
+
+    private function getSvg(&$v)
+    {
+        $v['type'] = 'svg';
+        $pattern = '/(width|height): [^;]+;/';
+        $replacement = 'width: 30px; height: 30px;';
+        $v['svg'] = preg_replace($pattern, $replacement, $v['svg']);
+        $v['class'] = '';
+    }
 }

+ 28 - 28
src/cate/lib/Info.php

@@ -1,29 +1,29 @@
-<?php namespace Cate\Lib;
-use Dever;
-class Info
-{
-    public function getManageList()
-    {
-        $where = array('status' => 1);
-        $parent = Dever::db('level_1', 'cate')->select($where);
-        $result = array();
-        foreach ($parent as $k => $v) {
-            $where['parent_id'] = $v['id'];
-            $v['children'] = Dever::db('level_2', 'cate')->select($where);
-            $result[] = $v;
-        }
-        return $result;
-    }
-
-    public function updateManageCate($db, $data)
-    {
-        if ($data['parent']) {
-            $parent = explode(',', $data['parent']);
-            $data['top_id'] = $parent[0];
-            if (isset($parent[1])) {
-                $data['parent_id'] = $parent[1];
-            }
-        }
-        return $data;
-    }
+<?php namespace Cate\Lib;
+use Dever;
+class Info
+{
+    public function getManageList()
+    {
+        $where = ['status' => 1];
+        $parent = Dever::db('level_1', 'cate')->select($where);
+        $result = [];
+        foreach ($parent as $k => $v) {
+            $where['parent_id'] = $v['id'];
+            $v['children'] = Dever::db('level_2', 'cate')->select($where);
+            $result[] = $v;
+        }
+        return $result;
+    }
+
+    public function updateManageCate($db, $data)
+    {
+        if ($data['parent']) {
+            $parent = explode(',', $data['parent']);
+            $data['top_id'] = $parent[0];
+            if (isset($parent[1])) {
+                $data['parent_id'] = $parent[1];
+            }
+        }
+        return $data;
+    }
 }

+ 36 - 42
src/cate/manage/core.php

@@ -1,42 +1,36 @@
-<?php
-return array
-(
-    'menu' => array
-    (
-        'cate_manage' => array
-        (
-            'parent' => 'setting',
-            'name' => '电商分类',
-            'icon' => 'briefcase-5-line',
-            'sort' => '2',
-            'app' => 'cate',
-        ),
-
-        'level_1' => array
-        (
-            'parent'    => 'cate_manage',
-            'name'      => '一级分类',
-            'icon'      => 'luggage-cart-line',
-            'sort'      => '1',
-            'app'       => 'cate',
-        ),
-
-        'level_2' => array
-        (
-            'parent'    => 'cate_manage',
-            'name'      => '二级分类',
-            'icon'      => 'calendar-todo-line',
-            'sort'      => '2',
-            'app'       => 'cate',
-        ),
-
-        'level_3' => array
-        (
-            'parent'    => 'cate_manage',
-            'name'      => '三级分类',
-            'icon'      => 'cast-line',
-            'sort'      => '3',
-            'app'       => 'cate',
-        ),
-    ),
-);
+<?php
+return [
+    'menu' => [
+        'cate_manage' => [
+            'parent' => 'setting',
+            'name' => '电商分类',
+            'icon' => 'briefcase-5-line',
+            'sort' => '2',
+            'app' => 'cate',
+        ],
+
+        'level_1' => [
+            'parent'    => 'cate_manage',
+            'name'      => '一级分类',
+            'icon'      => 'luggage-cart-line',
+            'sort'      => '1',
+            'app'       => 'cate',
+        ],
+
+        'level_2' => [
+            'parent'    => 'cate_manage',
+            'name'      => '二级分类',
+            'icon'      => 'calendar-todo-line',
+            'sort'      => '2',
+            'app'       => 'cate',
+        ],
+
+        'level_3' => [
+            'parent'    => 'cate_manage',
+            'name'      => '三级分类',
+            'icon'      => 'cast-line',
+            'sort'      => '3',
+            'app'       => 'cate',
+        ],
+    ],
+];

+ 45 - 58
src/cate/manage/level_1.php

@@ -1,58 +1,45 @@
-<?php
-return array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'name',
-            'icon_id' => array
-            (
-                'show' => 'Dever::call("cate/icon.show", "{icon_id}")',
-            ),
-            'sort' => array
-            (
-                'type' => 'input',
-                'tips' => '双击修改排序',
-            ),
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-            'cdate',
-        ),
-        'button' => array
-        (
-            '新增' => 'fastadd',
-        ),
-        'data_button' => array
-        (
-            '编辑' => 'fastedit',
-        ),
-        'search'    => array
-        (
-            'name',
-            'status',
-        ),
-    ),
-    'update' => array
-    (
-        'field'    => array
-        (
-            'name' => array
-            (
-                'rules' => true,
-            ),
-            'icon_id' => array
-            (
-                'type' => 'selector',
-                'option'    => 'Dever::url("cate/icon.getList", array("id" => "{icon_id}", "name" => "{name}"))',
-                'search' => 'icon_name',
-            ),
-            'icon_name' => 'hidden',
-        ),
-    ),
-);
+<?php
+return [
+    'list' => [
+        'field'      => [
+            'name',
+            'icon_id' => [
+                'show' => 'Dever::call("cate/icon.show", "{icon_id}")',
+            ],
+            'sort' => [
+                'type' => 'input',
+                'tips' => '双击修改排序',
+            ],
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+            'cdate',
+        ],
+        'button' => [
+            '新增' => 'fastadd',
+        ],
+        'data_button' => [
+            '编辑' => 'fastedit',
+        ],
+        'search'    => [
+            'name',
+            'status',
+        ],
+    ],
+    'update' => [
+        'field'    => [
+            'name' => [
+                'rules' => true,
+            ],
+            'icon_id' => [
+                'type' => 'selector',
+                'option'    => 'Dever::url("cate/icon.getList", ["id" => "{icon_id}", "name" => "{name}"])',
+                'search' => 'icon_name',
+            ],
+            'icon_name' => 'hidden',
+        ],
+    ],
+];

+ 52 - 66
src/cate/manage/level_2.php

@@ -1,66 +1,52 @@
-<?php
-return array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'name',
-            'parent_id',
-            'icon_id' => array
-            (
-                //'show' => '"{icon}" ? "<img src=\'{icon}\' width=\'50\' \/>" : ""',
-                'show' => 'Dever::call("cate/icon.show", "{icon_id}")',
-            ),
-            'sort' => array
-            (
-                'type' => 'input',
-                'tips' => '双击修改排序',
-            ),
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-            'cdate',
-        ),
-        'button' => array
-        (
-            '新增' => 'fastadd',
-        ),
-        'data_button' => array
-        (
-            '编辑' => 'fastedit',
-        ),
-        'search'    => array
-        (
-            'name' => 'like',
-            'parent_id',
-            'status',
-        ),
-    ),
-    'update' => array
-    (
-        'field'    => array
-        (
-            'name' => array
-            (
-                'rules' => true,
-            ),
-            'parent_id' => array
-            (
-                'type' => 'select',
-            ),
-            'icon_id' => array
-            (
-                'type' => 'selector',
-                'option'    => 'Dever::url("cate/icon.getList", array("id" => "{icon_id}", "name" => "{name}"))',
-                'search' => 'icon_name',
-            ),
-            'icon_name' => 'hidden',
-            #'desc' => 'textarea',
-        ),
-    ),
-);
+<?php
+return [
+    'list' => [
+        'field'      => [
+            'name',
+            'parent_id',
+            'icon_id' => [
+                //'show' => '"{icon}" ? "<img src=\'{icon}\' width=\'50\' \/>" : ""',
+                'show' => 'Dever::call("cate/icon.show", "{icon_id}")',
+            ],
+            'sort' => [
+                'type' => 'input',
+                'tips' => '双击修改排序',
+            ],
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+            'cdate',
+        ],
+        'button' => [
+            '新增' => 'fastadd',
+        ],
+        'data_button' => [
+            '编辑' => 'fastedit',
+        ],
+        'search'    => [
+            'name' => 'like',
+            'parent_id',
+            'status',
+        ],
+    ],
+    'update' => [
+        'field'    => [
+            'name' => [
+                'rules' => true,
+            ],
+            'parent_id' => [
+                'type' => 'select',
+            ],
+            'icon_id' => [
+                'type' => 'selector',
+                'option'    => 'Dever::url("cate/icon.getList", ["id" => "{icon_id}", "name" => "{name}"])',
+                'search' => 'icon_name',
+            ],
+            'icon_name' => 'hidden',
+            #'desc' => 'textarea',
+        ],
+    ],
+];

+ 61 - 78
src/cate/manage/level_3.php

@@ -1,78 +1,61 @@
-<?php
-return array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'name',
-            'top_id' => array
-            (
-                'show' => 'Dever::call("cate/level_1-find", "{top_id}")["name"]',
-            ),
-            'parent_id' => array
-            (
-                'show' => 'Dever::call("cate/level_2-find", "{parent_id}")["name"]',
-            ),
-            'icon_id' => array
-            (
-                //'show' => '"{icon}" ? "<img src=\'{icon}\' width=\'50\' \/>" : ""',
-                'show' => 'Dever::call("cate/icon.show", "{icon_id}")',
-            ),
-            'sort' => array
-            (
-                'type' => 'input',
-                'tips' => '双击修改排序',
-            ),
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-            'cdate',
-        ),
-        'button' => array
-        (
-            '新增' => 'fastadd',
-        ),
-        'data_button' => array
-        (
-            '编辑' => 'fastedit',
-        ),
-        'search'    => array
-        (
-            'name' => 'like',
-            'parent' => array
-            (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("cate/info.getManageList")',
-            ),
-            'status',
-        ),
-    ),
-    'update' => array
-    (
-        'field'    => array
-        (
-            'name' => array
-            (
-                'rules' => true,
-            ),
-            'parent' => array
-            (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("cate/info.getManageList")',
-            ),
-            'icon_id' => array
-            (
-                'type' => 'selector',
-                'option'    => 'Dever::url("cate/icon.getList", array("id" => "{icon_id}", "name" => "{name}"))',
-                'search' => 'icon_name',
-            ),
-            'icon_name' => 'hidden',
-        ),
-        'start' => 'cate/info.updateManageCate',
-    ),
-);
+<?php
+return [
+    'list' => [
+        'field'      => [
+            'name',
+            'top_id' => [
+                'show' => 'Dever::call("cate/level_1-find", "{top_id}")["name"]',
+            ],
+            'parent_id' => [
+                'show' => 'Dever::call("cate/level_2-find", "{parent_id}")["name"]',
+            ],
+            'icon_id' => [
+                //'show' => '"{icon}" ? "<img src=\'{icon}\' width=\'50\' \/>" : ""',
+                'show' => 'Dever::call("cate/icon.show", "{icon_id}")',
+            ],
+            'sort' => [
+                'type' => 'input',
+                'tips' => '双击修改排序',
+            ],
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+            'cdate',
+        ],
+        'button' => [
+            '新增' => 'fastadd',
+        ],
+        'data_button' => [
+            '编辑' => 'fastedit',
+        ],
+        'search'    => [
+            'name' => 'like',
+            'parent' => [
+                'type' => 'cascader',
+                'option'    => 'Dever::call("cate/info.getManageList")',
+            ],
+            'status',
+        ],
+    ],
+    'update' => [
+        'field'    => [
+            'name' => [
+                'rules' => true,
+            ],
+            'parent' => [
+                'type' => 'cascader',
+                'option'    => 'Dever::call("cate/info.getManageList")',
+            ],
+            'icon_id' => [
+                'type' => 'selector',
+                'option'    => 'Dever::url("cate/icon.getList", ["id" => "{icon_id}", "name" => "{name}"])',
+                'search' => 'icon_name',
+            ],
+            'icon_name' => 'hidden',
+        ],
+        'start' => 'cate/info.updateManageCate',
+    ],
+];

+ 23 - 29
src/cate/table/icon.php

@@ -1,29 +1,23 @@
-<?php
-return array
-(
-    'name' => '图标',
-    'order' => 'id asc',
-    'store' => 'log',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '图标名称',
-            'type'      => 'varchar(50)',
-        ),
-        'search_name' => array
-        (
-            'name'      => '搜索名称',
-            'type'      => 'varchar(50)',
-        ),
-        'svg' => array
-        (
-            'name'      => 'svg信息',
-            'type'      => 'text(255)',
-        ),
-    ),
-    'index' => array
-    (
-        'search' => 'search_name',
-    ),
-);
+<?php
+return [
+    'name' => '图标',
+    'order' => 'id asc',
+    'store' => 'log',
+    'struct' => [
+        'name' => [
+            'name'      => '图标名称',
+            'type'      => 'varchar(50)',
+        ],
+        'search_name' => [
+            'name'      => '搜索名称',
+            'type'      => 'varchar(50)',
+        ],
+        'svg' => [
+            'name'      => 'svg信息',
+            'type'      => 'text(255)',
+        ],
+    ],
+    'index' => [
+        'search' => 'search_name',
+    ],
+];

+ 34 - 42
src/cate/table/level_1.php

@@ -1,42 +1,34 @@
-<?php
-# 本来要做成一个表,后来思考很久,还是分开吧
-return array
-(
-    'name' => '一级分类表',
-    'order' => 'sort asc',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '分类名称',
-            'type'      => 'varchar(32)',
-        ),
-        'icon_name' => array
-        (
-            'name'      => '分类图标名称',
-            'type'      => 'varchar(32)',
-        ),
-        'icon_id' => array
-        (
-            'name'      => '分类图标',
-            'type'      => 'varchar(32)',
-        ),
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '可用',
-                2 => '不可用',
-            ),
-        ),
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => '1',
-        ),
-    ),
-);
+<?php
+# 本来要做成一个表,后来思考很久,还是分开吧
+return [
+    'name' => '一级分类表',
+    'order' => 'sort asc',
+    'struct' => [
+        'name' => [
+            'name'      => '分类名称',
+            'type'      => 'varchar(32)',
+        ],
+        'icon_name' => [
+            'name'      => '分类图标名称',
+            'type'      => 'varchar(32)',
+        ],
+        'icon_id' => [
+            'name'      => '分类图标',
+            'type'      => 'varchar(32)',
+        ],
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '可用',
+                2 => '不可用',
+            ],
+        ],
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ],
+    ],
+];

+ 38 - 47
src/cate/table/level_2.php

@@ -1,47 +1,38 @@
-<?php
-return array
-(
-    'name' => '二级分类表',
-    'order' => 'sort asc',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '分类名称',
-            'type'      => 'varchar(32)',
-        ),
-        'icon_name' => array
-        (
-            'name'      => '分类图标名称',
-            'type'      => 'varchar(32)',
-        ),
-        'parent_id' => array
-        (
-            'name'      => '一级分类',
-            'type'      => 'int(11)',
-            'value'     => 'cate/level_1',
-        ),
-        'icon_id' => array
-        (
-            'name'      => '分类图标',
-            'type'      => 'varchar(32)',
-        ),
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '可用',
-                2 => '不可用',
-            ),
-        ),
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => '1',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '二级分类表',
+    'order' => 'sort asc',
+    'struct' => [
+        'name' => [
+            'name'      => '分类名称',
+            'type'      => 'varchar(32)',
+        ],
+        'icon_name' => [
+            'name'      => '分类图标名称',
+            'type'      => 'varchar(32)',
+        ],
+        'parent_id' => [
+            'name'      => '一级分类',
+            'type'      => 'int(11)',
+            'value'     => 'cate/level_1',
+        ],
+        'icon_id' => [
+            'name'      => '分类图标',
+            'type'      => 'varchar(32)',
+        ],
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '可用',
+                2 => '不可用',
+            ],
+        ],
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ],
+    ],
+];

+ 45 - 56
src/cate/table/level_3.php

@@ -1,56 +1,45 @@
-<?php
-return array
-(
-    'name' => '三级级分类表',
-    'order' => 'sort asc',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '分类名称',
-            'type'      => 'varchar(32)',
-        ),
-        'icon_name' => array
-        (
-            'name'      => '分类图标名称',
-            'type'      => 'varchar(32)',
-        ),
-        'parent' => array
-        (
-            'name'      => '上级分类',
-            'type'      => 'varchar(1000)',
-        ),
-        'top_id' => array
-        (
-            'name'      => '一级分类',
-            'type'      => 'int(11)',
-        ),
-        'parent_id' => array
-        (
-            'name'      => '二级分类',
-            'type'      => 'int(11)',
-        ),
-        'icon_id' => array
-        (
-            'name'      => '分类图标',
-            'type'      => 'varchar(32)',
-        ),
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '可用',
-                2 => '不可用',
-            ),
-        ),
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => '1',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '三级级分类表',
+    'order' => 'sort asc',
+    'struct' => [
+        'name' => [
+            'name'      => '分类名称',
+            'type'      => 'varchar(32)',
+        ],
+        'icon_name' => [
+            'name'      => '分类图标名称',
+            'type'      => 'varchar(32)',
+        ],
+        'parent' => [
+            'name'      => '上级分类',
+            'type'      => 'varchar(1000)',
+        ],
+        'top_id' => [
+            'name'      => '一级分类',
+            'type'      => 'int(11)',
+        ],
+        'parent_id' => [
+            'name'      => '二级分类',
+            'type'      => 'int(11)',
+        ],
+        'icon_id' => [
+            'name'      => '分类图标',
+            'type'      => 'varchar(32)',
+        ],
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '可用',
+                2 => '不可用',
+            ],
+        ],
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ],
+    ],
+];

+ 17 - 12
src/place/act/lib/Core.php

@@ -7,7 +7,7 @@ class Core
     private $type;
     private $type_id;
     protected $data;
-    public static $instance = array();
+    public static $instance = [];
     public static function load($name, $type = false, $type_id = false)
     {
         if (empty(static::$instance[$name])) {
@@ -31,40 +31,45 @@ class Core
     }
 
     # 更新互动信息
-    public function up($data = array(), $msg = '')
+    public function up($data = [], $msg = '')
     {
         if ($this->getInfo($data)) {
             $msg && Dever::error($msg);
         } else {
             $state = $this->db->insert($this->data);
             if ($state) {
-                Dever::load('log', 'place_score')->add(Place::$uid, '互动', $this->db->config['name']);
+                # 这里可以判断一下是否优质的评价 以后加
+
+                Dever::load('log', 'place_score')->action('互动', $this->db->config['name'])->add(Place::$uid);
             }
         }
         return 'ok';
     }
 
     # 删除
-    public function del($data = array())
+    public function del($data = [])
     {
         $info = $this->getInfo($data);
         if ($info) {
             $state = $this->db->delete($info['id']);
             if ($state) {
-                Dever::load('log', 'place_score')->add(Place::$uid, '互动', '取消' . $this->db->config['name']);
+                Dever::load('log', 'place_score')->action('互动', '取消' . $this->db->config['name'])->add(Place::$uid);
             }
         }
         return 'ok';
     }
 
     # 获取用户互动相关的信息
-    public function getInfo($data = array(), $get = false, $field = array())
+    public function getInfo($data = [], $get = false, $field = [])
     {
         $this->check();
+        if ($data) {
+            $this->data = $data;
+        }
         $this->data['type'] = $this->type;
         $this->data['type_id'] = $this->type_id;
         $this->data['uid'] = Place::$uid;
-        $info = $this->db->find($data);
+        $info = $this->db->find($this->data);
         if ($get) {
             return $this->handleInfo($info, $field);
         }
@@ -87,7 +92,7 @@ class Core
                 if (Place::$uid == $v['uid']) {
                     $v['oper'] = 1;
                 }
-                $v['user'] = Dever::db('info', 'place_user')->find($v['uid'], array('col' => 'name,avatar'));
+                $v['user'] = Dever::db('info', 'place_user')->find($v['uid'], ['col' => 'name,avatar']);
             }
         }
         return $data;
@@ -103,7 +108,7 @@ class Core
     }
 
     # 获取用户的互动列表
-    public function getUserList($field = array(), $page = 10)
+    public function getUserList($field = [], $page = 10)
     {
         $where['uid'] = Place::$uid;
         if ($this->type) {
@@ -112,7 +117,7 @@ class Core
         # 每页10条
         $set['num'] = $page;
         $data = $this->db->select($where, $set);
-        $result = array();
+        $result = [];
         if ($data) {
             foreach ($data as $k => $v) {
                 $info = $this->handleInfo($v, $field);
@@ -133,10 +138,10 @@ class Core
         }
     }
 
-    private function handleInfo($v, $field = array())
+    private function handleInfo($v, $field = [])
     {
         if (!$v) {
-            return array();
+            return [];
         }
         $info = $this->getTypeInfo($v['type'], $v['type_id']);
         if ($info) {

+ 21 - 26
src/place/act/table/collect.php

@@ -1,26 +1,21 @@
-<?php
-return array
-(
-    'name' => '收藏',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-
-        'type'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '类型',
-        ),
-
-        'type_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '类型ID',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '收藏',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'type'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ],
+
+        'type_id'        => [
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ],
+    ],
+];

+ 21 - 26
src/place/act/table/like.php

@@ -1,26 +1,21 @@
-<?php
-return array
-(
-    'name' => '点赞',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-
-        'type'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '类型',
-        ),
-
-        'type_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '类型ID',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '点赞',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'type'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ],
+
+        'type_id'        => [
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ],
+    ],
+];

+ 33 - 40
src/place/act/table/review.php

@@ -1,40 +1,33 @@
-<?php
-return array
-(
-    'name' => '评价',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc',
-    'struct' => array
-    (
-        'type'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '类型',
-        ),
-
-        'type_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '类型ID',
-        ),
-
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-
-        'content'       => array
-        (
-            'name'      => '内容',
-            'type'      => 'varchar(2000)',
-        ),
-
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => '1',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '评价',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc',
+    'struct' => [
+        'type'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ],
+
+        'type_id'        => [
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ],
+
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'content'       => [
+            'name'      => '内容',
+            'type'      => 'varchar(2000)',
+        ],
+
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ],
+    ],
+];

+ 97 - 91
src/place/boot.php

@@ -1,92 +1,98 @@
-<?php
-# place 身份入口
-class Place
-{
-    public static $info;
-    public static $user;
-    public static $uid;
-    public static $code;
-    public static $nav;
-    public static $system;
-    public static $sector;
-    public static $module;
-    public static $id;
-
-    # 生成入口码
-    public static function entry($sector_id, $module_id, $user_id, $place_id)
-    {
-        $code = \Dever\Helper\Secure::encode($sector_id . '-' . $module_id . '-' . $user_id . '-' . $place_id);
-        return $code;
-    }
-
-    # 初始化
-    public static function init()
-    {
-        self::$code = Dever::input('p');
-        $code = Dever\Helper\Secure::decode(self::$code);
-        if (!$code) {
-            Dever::error('身份码错误');
-        }
-        list($sector_id, $module_id, $user_id, $place_id) = explode('-', $code);
-        self::$system = Dever::db('system', 'manage')->find(array('key' => 'sector'));
-        self::$sector = Dever::db(self::$system['info_table'])->find($sector_id);
-        if (!self::$sector) {
-            Dever::error('领域信息错误');
-        }
-        # 切换数据库
-        Dever::load('common', 'manage')->setAuth(self::$system['partition'], self::$system['id'], self::$sector['id'], $module_id, $user_id);
-
-        # 初始化身份
-        self::info($user_id, $place_id);
-
-        # 切换数据库
-        self::$module = Dever::db('system_module', 'manage')->find(array('key' => 'sector_place'));
-        Dever::load('common', 'manage')->setAuth(self::$system['partition'], self::$system['id'], self::$sector['id'], self::$module['id'], $place_id);
-    }
-
-    # 身份信息
-    public static function info($user_id, $place_id)
-    {
-        $user = Dever::db('user', 'sector')->find($user_id);
-        self::$info = Dever::db('info', 'place')->find($place_id, array('col' => 'name,logo,type,money_id,uid,pay_account,score_name,`update`'));
-        if (!self::$info) {
-            Dever::error('信息有误');
-        }
-        if (self::$info['uid'] != $user['id']) {
-            Dever::error('信息有误');
-        }
-        self::$id = $place_id;
-        self::$info['supplier'] = $user['supplier'];
-    }
-
-    # 用户信息
-    public static function user($uid)
-    {
-        self::$user = Dever::db('info', 'place_user')->find($uid, array('col' => 'id,name,avatar,sex,sign'));
-        if (self::$user) {
-            self::$uid = $uid;
-        }
-    }
-
-    # 菜单信息
-    public static function nav()
-    {
-        return Dever::db('nav', 'place')->select(['status' => 1], array('col' => 'id,name,type,type_id,icon,icon_select'));
-    }
-
-    # 支付的货币信息
-    public static function money()
-    {
-        return Dever::db('money', 'sector')->find(self::$info['money_id'], array('col' => 'name,code,sign,unit'));
-    }
-
-    public static function result($data)
-    {
-        $data['place'] = self::$info;
-        $data['user'] = self::$user;
-        $data['nav'] = self::nav();
-        $data['nav_select'] = $data['nav'][0]['id'];
-        return $data;
-    }
-}
+<?php
+# place 身份入口
+class Place
+{
+    public static $info;
+    public static $user;
+    public static $uid;
+    public static $code;
+    public static $nav;
+    public static $system;
+    public static $sector;
+    public static $module;
+    public static $id;
+
+    # 生成入口码
+    public static function entry($sector_id, $module_id, $user_id, $place_id)
+    {
+        $code = \Dever\Helper\Secure::encode($sector_id . '-' . $module_id . '-' . $user_id . '-' . $place_id);
+        return $code;
+    }
+
+    # 初始化
+    public static function init()
+    {
+        self::$code = Dever::input('p');
+        $code = Dever\Helper\Secure::decode(self::$code);
+        if (!$code) {
+            Dever::error('身份码错误');
+        }
+        list($sector_id, $module_id, $user_id, $place_id) = explode('-', $code);
+        self::$system = Dever::db('system', 'manage')->find(['key' => 'sector']);
+        self::$sector = Dever::db(self::$system['info_table'])->find($sector_id);
+        if (!self::$sector) {
+            Dever::error('领域信息错误');
+        }
+        # 切换数据库
+        Dever::load('common', 'manage')->setAuth(self::$system['partition'], self::$system['key'], self::$system['id'], self::$sector['id'], $module_id, $user_id);
+
+        # 初始化身份
+        self::info($user_id, $place_id);
+
+        # 切换数据库
+        self::$module = Dever::db('system_module', 'manage')->find(['key' => 'sector_place']);
+        Dever::load('common', 'manage')->setAuth(self::$system['partition'], self::$system['key'], self::$system['id'], self::$sector['id'], self::$module['id'], $place_id);
+    }
+
+    # 身份信息
+    public static function info($user_id, $place_id)
+    {
+        $user = Dever::db('user', 'sector')->find($user_id);
+        self::$info = Dever::db('info', 'place')->find($place_id, ['col' => 'name,info,logo,type,money_id,uid,pay_account,score_name,`update`']);
+        if (!self::$info) {
+            Dever::error('信息有误');
+        }
+        if (self::$info['uid'] != $user['id']) {
+            Dever::error('信息有误');
+        }
+        self::$id = $place_id;
+        self::$info['supplier'] = $user['supplier'];
+    }
+
+    # 用户信息
+    public static function user($uid)
+    {
+        self::$user = Dever::db('info', 'place_user')->find($uid, ['col' => 'id,name,mobile,password,avatar,sex,sign']);
+        if (self::$user) {
+            self::$uid = $uid;
+            self::$user['mobile'] = \Dever\Helper\Str::hide(self::$user['mobile']);
+            if (self::$user['password']) {
+                self::$user['password'] = 1;
+            } else {
+                self::$user['password'] = 2;
+            }
+        }
+    }
+
+    # 菜单信息
+    public static function nav()
+    {
+        return Dever::db('nav', 'place')->select(['status' => 1], ['col' => 'id,name,type,type_id,icon,icon_select']);
+    }
+
+    # 支付的货币信息
+    public static function money()
+    {
+        return Dever::db('money', 'sector')->find(self::$info['money_id'], ['col' => 'name,code,sign,unit']);
+    }
+
+    public static function result($data)
+    {
+        $data['place'] = self::$info;
+        $data['user'] = self::$user;
+        $data['nav'] = self::nav();
+        $data['nav_select'] = $data['nav'][0]['id'];
+        return $data;
+    }
+}
 include(DEVER_APP_PATH . '../../../boot.php');

+ 42 - 50
src/place/channel/table/seller.php

@@ -1,50 +1,42 @@
-<?php
-return array
-(
-    'name' => '销售网店渠道',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '网店名称',
-            'type'      => 'varchar(50)',
-        ),
-
-        'type' => array
-        (
-            'name'      => '类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '微信小店',
-                2 => '小红书',
-                3 => '抖店',
-                4 => '拼多多',
-                5 => '淘宝',
-                6 => '美团',
-            ),
-        ),
-
-        'status' => array
-        (
-            'name'      => '授权状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 2,
-            'value'     => array
-            (
-                1 => '已授权',
-                2 => '未授权',
-            ),
-        ),
-
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '销售网店渠道',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc',
+    'struct' => [
+        'name' => [
+            'name'      => '网店名称',
+            'type'      => 'varchar(50)',
+        ],
+
+        'type' => [
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '微信小店',
+                2 => '小红书',
+                3 => '抖店',
+                4 => '拼多多',
+                5 => '淘宝',
+                6 => '美团',
+            ],
+        ],
+
+        'status' => [
+            'name'      => '授权状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 2,
+            'value'     => [
+                1 => '已授权',
+                2 => '未授权',
+            ],
+        ],
+
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+    ],
+];

+ 38 - 46
src/place/channel/table/supplier.php

@@ -1,46 +1,38 @@
-<?php
-return array
-(
-    'name' => '供应商',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '供应商名称',
-            'type'      => 'varchar(50)',
-        ),
-
-        'mobile' => array
-        (
-            'name'      => '联系电话',
-            'type'      => 'varchar(50)',
-        ),
-
-        'type' => array
-        (
-            'name'      => '类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '源小货',
-                2 => '1688',
-            ),
-        ),
-
-        'type_id'       => array
-        (
-            'type'      => 'varchar(50)',
-            'name'      => '供应商ID',
-        ),
-
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '供应商',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc',
+    'struct' => [
+        'name' => [
+            'name'      => '供应商名称',
+            'type'      => 'varchar(50)',
+        ],
+
+        'mobile' => [
+            'name'      => '联系电话',
+            'type'      => 'varchar(50)',
+        ],
+
+        'type' => [
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '源小货',
+                2 => '1688',
+            ],
+        ],
+
+        'type_id'       => [
+            'type'      => 'varchar(50)',
+            'name'      => '供应商ID',
+        ],
+
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+    ],
+];

+ 43 - 7
src/place/interface/api/Address.php

@@ -10,7 +10,8 @@ class Address extends Core
     # 获取地址列表
     public function list()
     {
-        return Dever::load('address', 'place_user')->getList();
+        $data = Dever::load('address', 'place_user')->getList();
+        return ['list' => $data];
     }
 
 
@@ -18,11 +19,12 @@ class Address extends Core
     public function up()
     {
         $id = Dever::input('id');
-        $type = Dever::input('type', 'is_numeric', '类型', 1);
-        $province = Dever::input('province', 'is_numeric', '省份');
-        $city = Dever::input('city', 'is_numeric', '城市');
-        $county = Dever::input('county', 'is_numeric', '区县');
-        $town = Dever::input('town', 'is_numeric', '街镇');
+        $type = Dever::input('type', 'is_numeric', '类型', 0);
+        $type += 1;
+        $province = Dever::input('province_id', 'is_numeric', '省份');
+        $city = Dever::input('city_id', 'is_numeric', '城市');
+        $county = Dever::input('county_id', 'is_numeric', '区县');
+        $town = Dever::input('town_id', 'is_numeric', '街镇');
         $address = Dever::input('address', 'is_string', '地址');
         $name = Dever::input('name', 'is_string', '联系人');
         $phone = Dever::input('phone', 'is_string', '联系方式');
@@ -36,12 +38,46 @@ class Address extends Core
         return Dever::load('address', 'place_user')->getDefault();
     }
 
+    # 设置默认地址
+    public function setDefault()
+    {
+        $id = Dever::input('id');
+        return Dever::load('address', 'place_user')->setDefault($id);
+    }
+
     # 获取某个收货地址
     public function getInfo()
     {
         $id = Dever::input('id', 'is_numeric', '收货地址');
         $uid = Place::$uid;
-        return Dever::load('address', 'place_user')->getInfo($id, $uid);
+        $default = $this->getDefault();
+        if ($id > 0) {
+            $data = Dever::load('address', 'place_user')->getInfo($id, $uid);
+            if ($data) {
+                if ($default && $default['id'] != $id) {
+                    $data['type'] = 2;
+                }
+                $data['type'] -= 1;
+                if ($data['area']) {
+                    $data['area'] = 'CN,' . $data['area'];
+                }
+                $data['area'] = explode(',', $data['area']);
+                return $data;
+            }
+        }
+        return [
+            'province_id' => 0,
+            'city_id' => 0,
+            'county_id' => 0,
+            'town_id' => 0,
+            'address' => '',
+            'name' => '',
+            'phone' => '',
+            'type' => $default ? 1 : 0,
+            'area' => [],
+            'area_string' => '请选择地址',
+        ];
+        
     }
 
     # 删除地址

+ 0 - 52
src/place/interface/api/Agent.php

@@ -1,52 +0,0 @@
-<?php namespace Place_interface\Api;
-use Dever;
-use Place;
-use Place_interface\Lib\Core;
-use Place\Lib\Role;
-class Agent extends Core
-{
-    protected $login = true;
-    protected $entry = true;
-
-    public function __construct()
-    {
-        parent::__construct();
-        $this->role = new Role('agent', 3);
-    }
-
-    # 代理中心
-    public function home()
-    {
-        $data = Dever::db('agent', 'place_user')->find(array('uid' => Place::$uid));
-        return $data;
-    }
-
-    # 基本信息
-    public function getList()
-    {
-        return $this->role->getList();
-    }
-
-    # 确认支付
-    public function pay_confirm()
-    {
-        $id = Dever::input('id');
-        if (!$id) {
-            Dever::error('代理不存在');
-        }
-        $info = $this->role->getList($id);
-        if (!$info['list']) {
-            Dever::error('代理不存在');
-        }
-        $data = Dever::load('role/pay', 'place_order')->get($info['list']);
-        $data['money'] = Place::money();
-        return $data;
-    }
-
-    # 拉起支付
-    public function pay()
-    {
-        $this->pay_confirm();
-        return Dever::load('role/pay', 'place_order')->act();
-    }
-}

+ 1 - 1
src/place/interface/api/Collect.php

@@ -28,6 +28,6 @@ class Collect extends Core
 
     public function getUserList()
     {
-        return $this->act->getUserList();
+        return ['list' => $this->act->getUserList()];
     }
 }

+ 11 - 6
src/place/interface/api/Coupon.php

@@ -11,17 +11,22 @@ class Coupon extends Core
     public function getList()
     {
         $source_id = Dever::input('source_id');
-        $detail = array();
-        $set = array('col' => 'id,name,type,value,min,`limit`,date_type,date_day,date_start,date_end');
+        if (!$source_id) {
+            # 后续增加按照分类领取优惠券
+            Dever::error('error');
+        }
+        $detail = [];
+        $set = ['col' => 'id,name,type,value,min,`limit`,date_type,date_day,date_start,date_end'];
         if ($source_id) {
-            $detail = Dever::db('info', 'place_source')->select(['id' => $source_id], ['col' => '1 as coupon_type, id as coupon_type_id']);
+            $detail = Dever::db('info', 'place_source')->select(['id' => $source_id], ['col' => 'concat_ws(",",1,channel_id,cate_parent_id) as coupon_type, id as coupon_type_id,cate_id']);
+            $cate = Dever::load('cate', 'place_source')->getInfo($detail[0]['cate_id']);
             $set['num'] = 10;
         }
-        $data = array();
+        $data = [];
         $where = ['get' => 1, 'status' => 1];
         $list = Dever::db('coupon', 'place_source')->select($where, $set);
         if ($list) {
-            $t = array();
+            $t = [];
             foreach ($list as $k => $v) {
                 $state = false;
                 if (Place::$uid && $v['limit'] > 0) {
@@ -37,7 +42,7 @@ class Coupon extends Core
                 }
                 if ($state) {
                     $v['id'] = \Dever\Helper\Secure::encode($v['id']);
-                    $v = Dever::load('coupon', 'place_source')->getInfo($v);
+                    $v = Dever::load('coupon', 'place_source')->getInfo($v, $cate['score']);
                     $data[] = $v;
                 }
             }

+ 63 - 15
src/place/interface/api/Main.php

@@ -20,39 +20,58 @@ class Main extends Core
         } else {
             # 需要注册、购买、输入密码等等
             if (Place::$info['type'] == 2) {
-                $data['b'] = array
-                (
+                $data['b'] = [
                     'name' => '注册',
                     'type' => 2,
-                );
+                ];
             } elseif (Place::$info['type'] == 3) {
-                $data['b'] = array
-                (
+                $data['b'] = [
                     'name' => '邀请码',
                     'type' => 3,
-                );
+                ];
             } elseif (Place::$info['type'] == 4) {
-                $data['b'] = array
-                (
+                $data['b'] = [
                     'name' => '密码',
                     'type' => 4,
-                );
+                ];
             } elseif (Place::$info['type'] == 5) {
-                $data['b'] = array
-                (
+                $data['b'] = [
                     'name' => '购买',
                     'type' => 5,
-                );
+                ];
             }
         }
         //$data['i'] = htmlspecialchars_decode(Place::$info['content']);
         $data['n'] = Place::$info['name'];
+        $data['i'] = Place::$info['info'];
         $data['l'] = Place::$info['logo'];
         $data['u'] = Place::$info['update'];
         $data['m'] = Place::nav();
         return $data;
     }
 
+    # 获取个人中心首页需要的信息
+    public function getUserHome()
+    {
+        # 获取所有角色
+        $data['role'] = Dever::db('info', 'place_role')->select(['status' => 1], ['col' => 'id,name,info']);
+        $data['role_info'] = [];
+        if ($data['role']) {
+            foreach ($data['role'] as &$v) {
+                if ($v['info'] && !$data['role_info']) {
+                    $data['role_info'] = $v;
+                }
+                $v['level_name'] = '成为' . $v['name'];
+            }
+        }
+
+        # 获取所有积分
+        $data['score'] = Dever::db('info', 'place_score')->select(['status' => 1], ['col' => 'id,name,0 as num']);
+
+        return $data;
+
+    }
+
     # 验证码登录或者注册
     public function login_commit(){}
     public function login()
@@ -74,6 +93,7 @@ class Main extends Core
             }
             # 已注册,登录
             $uid = $user['id'];
+            Dever::load('log', 'place_score')->action('用户', '登录')->add($uid);
         } else {
             Dever::error('登录失败,账户无效');
         }
@@ -112,10 +132,10 @@ class Main extends Core
                 $parent = $db->find($parent_uid);
                 if ($parent) {
                     Dever::load('relation', 'invite')->set($parent_uid, $uid);
-                    $db->update($uid, array('parent_uid' => $parent_uid));
+                    $db->update($uid, ['parent_uid' => $parent_uid]);
                 }
             }
-            //Dever::load('log', 'place_score')->add($uid, '用户', '注册');
+            Dever::load('log', 'place_score')->action('用户', '注册')->add($uid);
         }
         return $this->result($account, $env, $uid);
     }
@@ -131,11 +151,24 @@ class Main extends Core
         return $result;
     }
 
+    # 重置密码
+    public function reset()
+    {
+        # 大于8位字符,至少包含:小写字母、大写字母、数字、特殊字符
+        //$pwd = Dever::input('pwd', '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/', '密码');
+        $mobile = Dever::input('mobile', 'is_numeric', '手机号');
+        $pwd = Dever::input('pwd', 'is_string', '密码');
+        $code = Dever::input('code', 'is_string', '验证码');
+        Dever::load('template', 'msg')->check('reg_code', $mobile, $code);
+        $update = Dever::load('manage/common')->createPwd($pwd);
+        Dever::db('info', 'place_user')->update(['mobile' => $mobile], $update);
+    }
+
     # 发送短信验证码
     public function sms()
     {
         $mobile = Dever::input('mobile', 'is_numeric', '手机号');
-        $data = Dever::load('template', 'msg')->send('reg_code', array('mobile' => $mobile));
+        $data = Dever::load('template', 'msg')->send('reg_code', ['mobile' => $mobile]);
         return $data;
     }
 
@@ -149,4 +182,19 @@ class Main extends Core
         }
         return $info;
     }
+
+    # 获取版权信息
+    public function version()
+    {
+        $data = [
+            'name' => '源代宝',
+            'info' => '让资源交易更简单',
+            'logo' => 'http://127.0.0.1/ydb/data/yuandaibao_v2/upload/3_1/5_1/1/f5/ad/4a/f5ad4a6f12853b9b155bca3ed26d2698.png?t=1748266972',
+            'site' => 'yuandaibao.com',
+            'company' => '北京时空之翼网络科技有限公司  版权所有',
+            'copyright' => 'Copyright © 2020-2025 Shemic. All Rights Reserved.',
+            'version' => 'v1.0.0',//后续增加
+        ];
+        return $data;
+    }
 }

+ 29 - 44
src/place/interface/api/Role.php

@@ -7,57 +7,42 @@ class Role extends Core
     protected $login = false;
     protected $entry = true;
 
-    # 我的信息
-    public function info()
+    # 角色信息
+    public function info($id = 0)
     {
-        $role_id = Dever::input('role_id', 'is_numeric', '角色ID');
-        $data['role'] = Dever::db('role', 'place_user')->find(array('id' => $role_id, 'status' => 1), array('col' => 'id,name,score_id'));
-        if (!$data['role']) {
-            Dever::error('角色信息错误');
-        }
-        $score = Dever::db('info', 'place_score')->find($data['role']['score_id']);
-        $data['role']['score_name'] = $score['name'];
-        # 获取当前等级
-        $user = array();
-        if (Place::$uid) {
-            $user = Dever::db('user_role', 'place_user')->find(array('role_id' => $role_id, 'uid' => Place::$uid));
-            if ($user) {
-                if ($user['edate']) {
-                    $user['edate_str'] = date('Y-m-d H:i:s', $user['edate']); 
-                } else {
-                    $user['edate_str'] = '永久'; 
-                }
-            }
-        }
-        
-        $data['level'] = Dever::db('role_level', 'place_user')->select(array('role_id' => $role_id, 'status' => 1), array('col' => 'id,name,level,icon,price,day_desc,day,content'));
-        if ($data['level']) {
-            foreach ($data['level'] as &$v) {
-                # 获取权益
-                $v['profit'] = Dever::load('role', 'place_user')->profit($v['id']);
-                $v['content'] = htmlspecialchars_decode($v['content']);
-                if ($user && $v['id'] == $user['level_id']) {
-                    $data['user'] = $v;
-                    $data['user']['edate_str'] = $user['edate_str'];
-                }
-            }
-        }
-        
+        $role_id = Dever::input('id', 'is_numeric', '角色ID', $id);
+        $data = Dever::load('info', 'place_role')->getData($role_id);
         return $data;
     }
 
-    # 获取价格
-    public function price()
-    {
-        return Dever::load('role', 'place_user')->getPrice();
-    }
-
-    # 购买
-    public function buy()
+    # 确认支付
+    public function pay_confirm()
     {
         if (!Place::$uid) {
             $this->showLogin();
         }
-        return Dever::load('role', 'place_user')->pay();
+        $role_id = Dever::input('type_id', 'is_numeric', '角色');
+        $role = Dever::load('info', 'place_role')->getInfo($role_id);
+        # 获取已经购买的
+        $role['user'] = Dever::load('user', 'place_role')->getInfo($role_id);
+
+        //[{"id":6,"num":2}]
+        $level = Dever::input('detail', 'is_string', '等级');
+        $level = Dever::json_decode($level);
+        if (!$level) {
+            Dever::error('角色等级不存在');
+        }
+        if (!isset($level[0])) {
+            Dever::error('角色等级不存在');
+        }
+        $data = Dever::load('role/pay', 'place_order')->get($level, $role);
+        return $data;
+    }
+
+    # 拉起支付
+    public function pay()
+    {
+        $this->pay_confirm();
+        return Dever::load('role/pay', 'place_order')->act();
     }
 }

+ 0 - 52
src/place/interface/api/Saler.php

@@ -1,52 +0,0 @@
-<?php namespace Place_interface\Api;
-use Dever;
-use Place;
-use Place_interface\Lib\Core;
-use Place\Lib\Role;
-class Saler extends Core
-{
-    protected $login = true;
-    protected $entry = true;
-
-    public function __construct()
-    {
-        parent::__construct();
-        $this->role = new Role('saler', 2);
-    }
-
-    # 分销中心
-    public function home()
-    {
-        $data = Dever::db('saler', 'place_user')->find(array('uid' => Place::$uid));
-        return $data;
-    }
-
-    # 基本信息
-    public function getList()
-    {
-        return $this->role->getList();
-    }
-
-    # 确认支付
-    public function pay_confirm()
-    {
-        $id = Dever::input('id');
-        if (!$id) {
-            Dever::error('分销员不存在');
-        }
-        $info = $this->role->getList($id);
-        if (!$info['list']) {
-            Dever::error('分销员不存在');
-        }
-        $data = Dever::load('role/pay', 'place_order')->get($info['list']);
-        $data['money'] = Place::money();
-        return $data;
-    }
-
-    # 拉起支付
-    public function pay()
-    {
-        $this->pay_confirm();
-        return Dever::load('role/pay', 'place_order')->act();
-    }
-}

+ 39 - 0
src/place/interface/api/Score.php

@@ -6,4 +6,43 @@ class Score extends Core
 {
     protected $login = true;
     protected $entry = true;
+
+    # 积分信息
+    public function info($id = 0)
+    {
+        $score_id = Dever::input('id', 'is_numeric', '积分ID', $id);
+        $data = Dever::load('info', 'place_score')->getInfo($score_id, Place::$uid);
+        return $data;
+    }
+
+    # 确认支付
+    public function pay_confirm()
+    {
+        if (!Place::$uid) {
+            $this->showLogin();
+        }
+        $role_id = Dever::input('type_id', 'is_numeric', '角色');
+        $role = Dever::load('info', 'place_role')->getInfo($role_id);
+        # 获取已经购买的
+        $role['user'] = Dever::load('user', 'place_role')->getInfo($role_id);
+
+        //[{"id":6,"num":2}]
+        $level = Dever::input('detail', 'is_string', '等级');
+        $level = Dever::json_decode($level);
+        if (!$level) {
+            Dever::error('角色等级不存在');
+        }
+        if (!isset($level[0])) {
+            Dever::error('角色等级不存在');
+        }
+        $data = Dever::load('role/pay', 'place_order')->get($level, $role);
+        return $data;
+    }
+
+    # 拉起支付
+    public function pay()
+    {
+        $this->pay_confirm();
+        return Dever::load('role/pay', 'place_order')->act();
+    }
 }

+ 29 - 23
src/place/interface/api/Source.php

@@ -12,15 +12,14 @@ class Source extends Core
         # 获取频道信息
         $channel = Dever::load('channel', 'place_source')->getInfo($channel_id);
 
-        $data['channel'] = array
-        (
+        $data['channel'] = [
             'id'    => $channel['id'],
             'name'  => $channel['name'],
             'desc'  => $channel['desc'],
-        );
+        ];
         # 分类信息
         $top_id = 0;
-        $data['top'] = array();
+        $data['top'] = [];
         if ($channel['type'] == 1) {
             # 显示子分类
             # 根据频道获取主分类
@@ -33,7 +32,7 @@ class Source extends Core
         $data['cate'] = Dever::load('cate', 'place_source')->getData($channel, $top_id);
 
         # 主页轮播、主页小导航、主页信息流
-        $data['ad'] = Dever::load('ad', 'place_source')->gets(array(1,2,3,4,5), $channel_id, $top_id);
+        $data['ad'] = Dever::load('ad', 'place_source')->gets([1,2,3,4,5], $channel_id, $top_id);
 
         return $data;
     }
@@ -43,15 +42,14 @@ class Source extends Core
     {
         $cate_id = Dever::input('id', 'is_numeric', '分类ID');
         $cate = Dever::load('cate', 'place_source')->getInfo($cate_id);
-        $data['cate'] = array
-        (
+        $data['cate'] = [
             'id'    => $cate['id'],
             'name'  => $cate['name'],
             'desc'  => $cate['desc'],
-        );
+        ];
         $data['list'] = Dever::load('info', 'place_source')->getList($cate, false, 10);
 
-        $data['child'] = array();
+        $data['child'] = [];
         if ($cate['parent_id'] == 0) {
             $cate_id = $cate['id'];
             $data['child'] = Dever::load('cate', 'place_source')->getList($cate['channel_id'], $cate['id']);
@@ -60,7 +58,7 @@ class Source extends Core
         }
 
         # 列表页轮播图、列表页信息流
-        $data['ad'] = Dever::load('ad', 'place_source')->gets(array(11,12), $cate['channel_id'], $cate_id);
+        $data['ad'] = Dever::load('ad', 'place_source')->gets([11,12], $cate['channel_id'], $cate_id);
 
         return $data;
     }
@@ -70,9 +68,9 @@ class Source extends Core
     {
         $source_id = Dever::input('id', 'is_numeric', '资源ID');
         $info = Dever::load('info', 'place_source')->getInfo($source_id);
-        $data['info'] = array
-        (
+        $data['info'] = [
             'id'            => $info['id'],
+            'cate_id'       => $info['cate_id'],
             'name'          => $info['name'],
             'sku_name'      => $info['sku_name'],
             'price'         => $info['price'],
@@ -84,14 +82,14 @@ class Source extends Core
             'stock'         => $info['stock'],
             'pic'           => $info['pic'],
             'content'       => $info['content'],
-        );
+        ];
         $data['have_vip'] = $info['have_vip'];
         $data['help'] = $info['help'];
 
         # 是否收藏
         $data['collect'] = $info['collect'];
         # 是否展示内容
-        $content = Dever::db('content', 'place_source')->find(array('info_id' => $source_id));
+        $content = Dever::db('content', 'place_source')->find(['info_id' => $source_id]);
         $data['content'] = false;
         if ($content) {
             $data['content'] = true;
@@ -103,7 +101,7 @@ class Source extends Core
         $data['review_total'] = Act::load('review', 1, $source_id)->getTotal();
 
         # 详情页轮播、详情页信息流
-        $data['ad'] = Dever::load('ad', 'place_source')->gets(array(21,22), $info['channel_id'], $info['cate_parent_id']);
+        $data['ad'] = Dever::load('ad', 'place_source')->gets([21,22], $info['channel_id'], $info['cate_parent_id']);
 
         return $data;
     }
@@ -125,7 +123,7 @@ class Source extends Core
         $data['content'] = Dever::load('content', 'place_source')->getList($source_id, $data['cate_id']);
 
         # 内容页轮播、内容页信息流
-        $data['ad'] = Dever::load('ad', 'place_source')->gets(array(31,32), $source['channel_id'], $source['cate_parent_id']);
+        $data['ad'] = Dever::load('ad', 'place_source')->gets([31,32], $source['channel_id'], $source['cate_parent_id']);
         return $data;
     }
 
@@ -144,10 +142,19 @@ class Source extends Core
         if (!Place::$uid) {
             $this->showLogin();
         }
+        $cate_id = Dever::input('type_id', 'is_numeric', '分类ID');
+        $cate = Dever::load('cate', 'place_source')->getInfo($cate_id);
+
         //[{"id":6,"sku_id":10,"num":2}]
-        $source = Dever::input('source', 'is_string', '资源');
+        $source = Dever::input('detail', 'is_string', '资源');
         $source = Dever::json_decode($source);
-        $data = Dever::load('source/pay', 'place_order')->get($source);
+        if (!$source) {
+            Dever::error('资源不存在');
+        }
+        if (!isset($source[0])) {
+            Dever::error('资源不存在');
+        }
+        $data = Dever::load('source/pay', 'place_order')->get($source, $cate);
         return $data;
     }
 
@@ -184,18 +191,17 @@ class Source extends Core
         $status = Dever::input('status');
         if ($status) {
             if ($status == 10) {
-                $where['or'] = array
-                (
+                $where['or'] = [
                     'refund_status' => '1',
                     'status' => '8',
-                );
+                ];
                 $where = ' uid = ' . $where['uid'] . ' and (refund_status = 1 or status = 8)';
             } else {
-                $where['status'] = array('in', $status);
+                $where['status'] = ['in', $status];
             }
         }
         $data = Dever::db('source', 'place_order')->select($where, $set);
-        $result = array();
+        $result = [];
         if ($data) {
             foreach ($data as $k => $v) {
                 $order = $this->getOrderInfo($v);

+ 1 - 1
src/place/interface/api/Tool.php

@@ -11,7 +11,7 @@ class Tool
         if (!$code) {
             Dever::error('请输入身份码');
         }
-        $code = Dever::db('code', 'place')->find(array('code' => $code));
+        $code = Dever::db('code', 'place')->find(['code' => $code]);
         if (!$code) {
             Dever::error('身份码错误');
         }

+ 59 - 22
src/place/interface/api/User.php

@@ -12,32 +12,68 @@ class User extends Core
     {
         $data['user'] = Place::$user;
         $data['user']['coupon'] = 0;
-        $data['user']['vip_name'] = $data['user']['saler_name'] = $data['user']['agent_name'] = '';
-        if ($data['user']['vip_id'] > 0) {
-            $vip = Dever::db('vip', 'place')->find(['id' => $data['user']['vip_id']]);
-            if ($vip) {
-                $data['user']['vip_name'] = $vip['name'];
-            }
-        }
-        if ($data['user']['saler_id'] > 0) {
-            $saler = Dever::db('saler', 'place')->find(['id' => $data['user']['saler_id']]);
-            if ($saler) {
-                $data['user']['saler_name'] = $saler['name'];
+
+        $data['role'] = [];
+        $role = Dever::db('info', 'place_role')->select(['status' => 1], ['col' => 'id,name,info']);
+        # 获取用户的角色
+        $user_role = Dever::load('user', 'place_role')->getList(Place::$uid);
+        $data['role_info'] = [];
+        if ($role) {
+            foreach ($role as $v) {
+                $level = Dever::db('level', 'place_role')->find(['info_id' => $v['id']]);
+                if (!$level) {
+                    continue;
+                }
+                $state = Dever::db('profit_buy', 'place_role')->find(['level_id' => $level['id'], 'status' => 1]);
+                if (!$state) {
+                    $state = Dever::db('profit_sale', 'place_role')->find(['level_id' => $level['id'], 'status' => 1]);
+                    if (!$state) {
+                        $state = Dever::db('profit_partner', 'place_role')->find(['level_id' => $level['id'], 'status' => 1]);
+                        if (!$state) {
+                            continue;
+                        }
+                    }
+                }
+                if (isset($user_role[$v['id']])) {
+                    $v['subname'] = $user_role[$v['id']];
+                    $v['button'] = '了解详情';
+                } else {
+                    $v['subname'] = $v['info'];
+                    $v['button'] = '立即开通';
+                }
+                
+                if ($v['info'] && !$data['role_info']) {
+                    $data['role_info'] = $v;
+                }
+                $data['role'][] = $v;
             }
         }
-        if ($data['user']['agent_id'] > 0) {
-            $agent = Dever::db('agent', 'place')->find(['id' => $data['user']['agent_id']]);
-            if ($agent) {
-                $data['user']['agent_name'] = $agent['name'];
+
+        # 获取所有积分
+        $data['score'] = Dever::db('info', 'place_score')->select(['status' => 1], ['col' => 'id,name']);
+        # 获取用户的积分
+        $user_score = Dever::load('user', 'place_score')->getList(Place::$uid);
+        if ($data['score']) {
+            foreach ($data['score'] as &$score) {
+                $score['num'] = $user_score[$score['id']] ?? 0;
             }
         }
+
         return $data;
     }
 
+    # 上传图片
+    public function upload()
+    {
+        $file = Dever::input('file', '!empty', '上传文件错误');
+        $uid = Place::$uid;
+        return Dever::load('save', 'upload')->init(7, 1, false, $uid)->act($file, 'png', $uid);
+    }
+
     # 更新我的信息
     public function update()
     {
-        $update = array();
+        $update = [];
         $name = Dever::input('name');
         if ($name) {
             Place::$user['name'] = $update['name'] = $name;
@@ -64,7 +100,8 @@ class User extends Core
     public function pwd()
     {
         # 大于8位字符,至少包含:小写字母、大写字母、数字、特殊字符
-        $pwd = Dever::input('pwd', '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/', '密码');
+        //$pwd = Dever::input('pwd', '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/', '密码');
+        $pwd = Dever::input('pwd', 'is_string', '密码');
         $code = Dever::input('code', 'is_string', '验证码');
         Dever::load('template', 'msg')->check('user_code', Place::$user['mobile'], $code);
         $update = Dever::load('manage/common')->createPwd($pwd);
@@ -74,7 +111,7 @@ class User extends Core
     # 发送短信验证码
     public function sms()
     {
-        $data = Dever::load('template', 'msg')->send('user_code', array('mobile' => Place::$user['mobile']));
+        $data = Dever::load('template', 'msg')->send('user_code', ['mobile' => Place::$user['mobile']]);
         return $data;
     }
 
@@ -89,7 +126,7 @@ class User extends Core
         $relation = Dever::load('relation', 'invite')->getParent(Place::$uid);
         if ($relation) {
             $data['parent'] = 1;
-            $data['parent_info'] = Dever::db('info', 'place_user')->find($relation['uid'], array('col' => 'id,name,avatar'));
+            $data['parent_info'] = Dever::db('info', 'place_user')->find($relation['uid'], ['col' => 'id,name,avatar']);
         }
         return $data;
     }
@@ -98,10 +135,10 @@ class User extends Core
     public function getGroup()
     {
         $relation = Dever::load('relation', 'invite')->getChild(Place::$uid);
-        $result = array();
+        $result = [];
         if ($relation) {
             foreach ($relation as $k => $v) {
-                $result[$k] = Dever::db('info', 'place_user')->find($v['to_uid'], array('col' => 'id,name,avatar'));
+                $result[$k] = Dever::db('info', 'place_user')->find($v['to_uid'], ['col' => 'id,name,avatar']);
                 $result[$k]['cdate_str'] = date('Y-m-d H:i:s', $v['cdate']);
             }
         }
@@ -125,7 +162,7 @@ class User extends Core
             Dever::error('邀请码不存在');
         }
         Dever::load('relation', 'invite')->set($parent_uid, Place::$uid);
-        Dever::db('info', 'place_user')->update(Place::$uid, array('parent_uid' => $parent_uid));
+        Dever::db('info', 'place_user')->update(Place::$uid, ['parent_uid' => $parent_uid]);
         return 'ok';
     }
 }

+ 0 - 45
src/place/interface/api/Vip.php

@@ -1,45 +0,0 @@
-<?php namespace Place_interface\Api;
-use Dever;
-use Place;
-use Place_interface\Lib\Core;
-use Place\Lib\Role;
-class Vip extends Core
-{
-    protected $login = true;
-    protected $entry = true;
-
-    public function __construct()
-    {
-        parent::__construct();
-        $this->role = new Role('vip', 1);
-    }
-
-    # 基本信息
-    public function getList()
-    {
-        return $this->role->getList();
-    }
-
-    # 确认支付
-    public function pay_confirm()
-    {
-        $id = Dever::input('id');
-        if (!$id) {
-            Dever::error('会员不存在');
-        }
-        $info = $this->role->getList($id);
-        if (!$info['list']) {
-            Dever::error('会员不存在');
-        }
-        $data = Dever::load('role/pay', 'place_order')->get($info['list']);
-        $data['money'] = Place::money();
-        return $data;
-    }
-
-    # 拉起支付
-    public function pay()
-    {
-        $this->pay_confirm();
-        return Dever::load('role/pay', 'place_order')->act();
-    }
-}

+ 0 - 9
src/place/interface/api/Wallet.php

@@ -1,9 +0,0 @@
-<?php namespace Place_interface\Api;
-use Dever;
-use Place;
-use Place_interface\Lib\Core;
-class Wallet extends Core
-{
-    protected $login = true;
-    protected $entry = true;
-}

+ 194 - 159
src/place/order/lib/Pay.php

@@ -1,160 +1,195 @@
-<?php namespace Place_order\Lib;
-use Dever;
-use Place;
-
-class Pay
-{
-    protected $type = '';
-    protected $order = array();
-    protected $detail = array();
-    protected $user = array();
-    protected $coupon = array();
-
-    # 获取支付需要的信息
-    public function get($detail)
-    {
-        $this->order['cash'] = $this->order['num'] = 0;
-        $this->order['name'] = array();
-        foreach ($detail as $k => $v) {
-            $this->getDetail($v);
-        }
-        $this->getUser();
-        $this->getOrder();
-        return ['order' => $this->order, 'detail' => $this->detail, 'user' => $this->user];
-    }
-
-    # 获取用户信息
-    private function getUser()
-    {
-        $address_id = Dever::input('address_id');
-        $user_coupon_id = Dever::input('user_coupon_id');
-        $coupon_cash = Dever::input('coupon_cash');
-
-        # 获取当前余额
-        $this->user['wallet'] = Dever::number(Place::$user['wallet']);
-        # 获取当前可用的优惠券
-        $this->user['coupon'] = Dever::load('coupon', 'place_user')->getUseList($this->detail, $user_coupon_id, $coupon_cash);
-
-        # 获取地址
-        if ($address_id) {
-            $this->user['address'] = Dever::load('address', 'place_user')->getInfo($address_id, Place::$uid);
-        } else {
-            $this->user['address'] = Dever::load('address', 'place_user')->getDefault();
-        }
-    }
-
-    # 获取订单信息
-    private function getOrder()
-    {
-        $this->order['uid'] = Place::$uid;
-        if (is_array($this->order['name'])) {
-            $this->order['name'] = implode('、', $this->order['name']);
-        }
-        $this->order['cash'] = Dever::number($this->order['cash']);
-        # 支付金额
-        $this->order['pay_cash'] = $this->order['cash'];
-        # 使用的钱包金额和优惠券金额
-        $this->order['user_coupon_id'] = $this->order['wallet_cash'] = $this->order['coupon_cash'] = 0;
-
-        # 优惠券
-        $this->getCoupon();
-
-        # 钱包
-        $this->getWallet();
-
-        $this->order['pay_cash'] = Dever::number($this->order['pay_cash']);
-
-        if ($this->user['address']) {
-            $this->order['address_id'] = $this->user['address']['id'];
-        }
-    }
-
-    # 优惠券
-    private function getCoupon()
-    {
-        $this->coupon = array();
-        if ($this->user['coupon']) {
-            $this->coupon = $this->user['coupon'][0];
-            $this->order['user_coupon_id'] = $this->coupon['id'];
-            $this->order['coupon_cash'] = Dever::number($this->coupon['cash']);
-            $this->order['pay_cash'] -= $this->order['coupon_cash'];
-        }
-    }
-
-    # 钱包
-    private function getWallet()
-    {
-        $wallet = Dever::input('wallet');
-        if ($wallet > 0 && Place::$user['wallet'] >= $wallet) {
-            $this->order['wallet_cash'] = Dever::number($wallet);
-            $this->order['pay_cash'] -= $this->order['wallet_cash'];
-        }
-    }
-
-    # 下单
-    public function act_commit(){}
-    public function act($detail = false)
-    {
-        if ($detail) {
-            $this->get($detail);
-        }
-        if (!$this->order) {
-            Dever::error('订单不存在');
-        }
-        $this->check();
-        
-        $table = 'place_order/' . $this->type;
-        $prefix = strtoupper(substr($this->type, 0, 2));
-
-        $this->order['uid'] = Place::$uid;
-        $this->order['order_num'] = Dever::load('util', 'api')->createNumber($prefix, $table);
-        $this->order['notify'] = $table . '/pay.notify|' . Dever::input('p') . '|' . $this->order['order_num'];
-        $this->order['info'] = Dever::input('remark');
-
-        $result = array();
-        if ($this->order['pay_cash'] > 0) {
-            $result['pay'] = Dever::load('account', 'place')->pay($this->order);
-            if (isset($result['pay']['link']) && $result['pay']['link']) {
-                return $result;
-            }
-        } else {
-            $result['pay'] = true;
-        }
-        if ($result['pay']) {
-            $result['order_id'] = Dever::db($table)->insert($this->order);
-
-            if ($result['order_id']) {
-                # 使用优惠券
-                if ($this->coupon) {
-                    Dever::load('coupon', 'place_user')->use(1, $result['order_id'], $this->coupon);
-                }
-                # 使用钱包支付
-                if ($this->order['wallet_cash'] > 0) {
-                    if ($this->type == 'source') {
-                        $type = 11;
-                    } else {
-                        $type = 12;
-                    }
-                    Dever::load('wallet', 'place_user')->up($this->order['uid'], 2, $type, $result['order_id'], $this->order['wallet_cash']);
-                }
-                $result['order_num'] = $this->order['order_num'];
-                $this->success($result['order_id']);
-
-                if ($result['pay'] === true) {
-                    $this->notify(Dever::input('p'), $result['order_num'], 1);
-                }
-            }
-        }
-        return $result;
-    }
-
-    # 支付回调
-    public function notify($place, $order_num, $status, $body = array())
-    {
-        Dever::input('authorization', 'is_string', '入口码', $place);
-        $order = Dever::db('place_order/' . $this->type)->find(array('order_num' => $order_num));
-        if ($order && $order['status'] == 1) {
-            $this->callback($order, $status);
-        }
-    }
+<?php namespace Place_order\Lib;
+use Dever;
+use Place;
+
+class Pay
+{
+    protected $type = '';
+    protected $order = [];
+    protected $detail = [];
+    protected $user = [];
+    protected $coupon = [];
+    protected $set = [];
+
+    # 获取支付需要的信息
+    public function get($detail, $set)
+    {
+        if (empty($set['score'])) {
+            Dever::error('积分规则不能为空');
+        }
+        $this->set = $set;
+        $this->order['cash'] = $this->order['num'] = 0;
+        $this->order['name'] = [];
+        foreach ($detail as $k => $v) {
+            $this->getDetail($v);
+        }
+        $this->getUser();
+        $this->getOrder();
+        return ['order' => $this->order, 'detail' => $this->detail, 'user' => $this->user, 'rebate' => $this->set['rebate']];
+    }
+
+    # 获取用户信息
+    private function getUser()
+    {
+        $address_id = Dever::input('address_id');
+        $coupon_id = Dever::input('coupon_id');
+        $coupon_cash = Dever::input('coupon_cash');
+
+        # 获取当前余额
+        $this->user['wallet'] = Dever::load('user', 'place_score')->getInfo(Place::$uid, $this->set['score']);
+
+        # 获取当前可用的优惠券
+        $this->user['coupon'] = Dever::load('coupon', 'place_user')->getUseList($this->detail, $this->set['score'], $coupon_id, $coupon_cash);
+
+        # 获取地址
+        if (isset($this->order['deliver_type']) && $this->order['deliver_type'] == 1) {
+            if ($address_id) {
+                $this->user['address'] = Dever::load('address', 'place_user')->getInfo($address_id, Place::$uid);
+            } else {
+                $this->user['address'] = Dever::load('address', 'place_user')->getDefault();
+            }
+        }
+    }
+
+    # 获取订单信息
+    private function getOrder()
+    {
+        $this->order['uid'] = Place::$uid;
+        if (is_[$this->order['name']]) {
+            $this->order['name'] = implode('、', $this->order['name']);
+        }
+        $this->order['cash'] = Dever::number($this->order['cash']);
+        # 支付金额
+        $this->order['pay_cash'] = $this->order['cash'];
+        # 使用的钱包金额和优惠券金额
+        $this->order['user_coupon_id'] = $this->order['wallet_cash'] = $this->order['coupon_cash'] = 0;
+
+        # 优惠券
+        $this->getCoupon();
+
+        # 钱包
+        $this->getWallet();
+
+        $this->order['pay_cash'] = Dever::number($this->order['pay_cash']);
+        $this->order['pay_money_cash'] = Dever::number($this->order['pay_cash'] * $this->set['score']['exp']);
+        $this->set['rebate'] = Dever::load('price', 'place_source')->getRebate($this->order['pay_cash'], $this->set['rebate']);
+        list(
+            $this->order['cash_text'], 
+            $this->order['pay_cash_text'], 
+            $this->order['wallet_cash_text'], 
+            $this->order['coupon_cash_text'],
+            $tip,
+        ) = Dever::load('info', 'place_score')->getText(
+            [
+                $this->order['cash'], 
+                $this->order['pay_cash'], 
+                $this->order['wallet_cash'], 
+                $this->order['coupon_cash'],
+                1
+            ], $this->set['score']);
+
+        if (isset($this->user['address']) && $this->user['address']) {
+            $this->order['address_id'] = $this->user['address']['id'];
+        }
+        $money = Place::money();
+        $this->order['score_id'] = $this->set['score']['id'];
+        $this->order['score_exp'] = $this->set['score']['exp'];
+        $this->order['score_tip'] = $tip . '=' .(1*$this->order['score_exp']) . $money['unit'] . $money['name'];
+    }
+
+    # 优惠券
+    private function getCoupon()
+    {
+        $this->coupon = [];
+        $coupon_id = Dever::input('coupon_id');
+        if ($this->user['coupon'] && $coupon_id != -1) {
+            $this->coupon = $this->user['coupon'][0];
+            if ($this->coupon['cash'] > 0) {
+                $this->order['user_coupon_id'] = $this->coupon['id'];
+                $this->order['coupon_cash'] = Dever::number($this->coupon['cash']);
+                $this->order['pay_cash'] -= $this->order['coupon_cash'];
+            }
+        }
+    }
+
+    # 钱包
+    private function getWallet()
+    {
+        $wallet = Dever::input('wallet');
+        if ($wallet > 0 && $this->user['wallet']['yue'] >= $wallet) {
+            if ($wallet > $this->order['pay_cash']) {
+                $wallet = $this->order['pay_cash'];
+            }
+            $this->order['wallet_cash'] = Dever::number($wallet);
+            $this->order['pay_cash'] -= $this->order['wallet_cash'];
+        }
+    }
+
+    # 下单
+    public function act_commit(){}
+    public function act($detail = false)
+    {
+        if ($detail) {
+            $this->get($detail);
+        }
+        if (!$this->order) {
+            Dever::error('订单不存在');
+        }
+        $this->check();
+        
+        $table = 'place_order/' . $this->type;
+        $prefix = strtoupper(substr($this->type, 0, 2));
+
+        $this->order['uid'] = Place::$uid;
+        $this->order['order_num'] = Dever::load('util', 'api')->createNumber($prefix, $table);
+        $this->order['notify'] = $table . '/pay.notify|' . Dever::input('p') . '|' . $this->order['order_num'];
+        $this->order['info'] = Dever::input('remark');
+
+        $result = [];
+        if ($this->order['pay_money_cash'] > 0) {
+            $result['pay'] = Dever::load('account', 'place')->pay($this->order);
+            if (isset($result['pay']['link']) && $result['pay']['link']) {
+                return $result;
+            }
+        } else {
+            $result['pay'] = true;
+        }
+        if ($result['pay']) {
+            $result['order_id'] = Dever::db($table)->insert($this->order);
+
+            if ($result['order_id']) {
+                # 使用优惠券
+                if ($this->coupon) {
+                    Dever::load('coupon', 'place_user')->use(1, $result['order_id'], $this->coupon);
+                }
+                # 使用钱包支付
+                if ($this->order['wallet_cash'] > 0) {
+                    Dever::load('log', 'place_score')
+                    ->action('订单', '下单', 11)
+                    ->score($this->order['score_id'])
+                    ->add($this->order['uid'], $this->order['wallet_cash']*-1, $this->order['name']);
+                }
+                $result['order_num'] = $this->order['order_num'];
+                $this->success($result['order_id']);
+
+                if ($result['pay'] === true) {
+                    $this->notify(Dever::input('p'), $result['order_num'], 1);
+                }
+            }
+        }
+        return $result;
+    }
+
+    # 支付回调
+    public function notify($place, $order_num, $status, $body = [])
+    {
+        Dever::input('authorization', 'is_string', '入口码', $place);
+        $order = Dever::db('place_order/' . $this->type)->find(['order_num' => $order_num]);
+        if ($order && $order['status'] == 1) {
+            if ($status != 1) {
+                # 恢复钱包、优惠券
+            }
+            $this->callback($order, $status);
+        }
+    }
 }

+ 45 - 0
src/place/order/lib/Role/Log.php

@@ -0,0 +1,45 @@
+<?php namespace Place_order\Lib\Role;
+use Dever;
+use Place;
+class Log
+{
+    public function up($type, $type_id, $order_id, $desc)
+    {
+        $update['type'] = $type;
+        $update['type_id'] = $type_id;
+        $update['order_id'] = $order_id;
+        $update['desc'] = $desc;
+        Dever::db('role_log', 'place_order')->insert($update);
+    }
+
+    # 获取日志信息
+    public function getList($order_id)
+    {
+        $log = Dever::db('role_log', 'place_order')->select(['order_id' => $order_id]);
+        if ($log) {
+            foreach ($log as &$v) {
+                $v = $this->getInfo($v);
+            }
+        }
+        return $log;
+    }
+
+    # 获取日志信息
+    public function getInfo($info)
+    {
+        if ($info['type'] == 1) {
+            $user = Dever::db('info', 'place_user')->find($info['type_id']);
+        } elseif ($info['type'] == 2) {
+            $user = Dever::db('user', 'sector')->find($info['type_id']);
+        } elseif ($info['type'] == 3) {
+            $user = Dever::db('supplier', 'place')->find($info['type_id']);
+        } else {
+            $user['name'] = $user['mobile'] = '-';
+        }
+        $info['type'] = Dever::db('role_log', 'place_order')->value('type', $info);
+        $info['name'] = $user['name'];
+        $info['mobile'] = $user['mobile'];
+        $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
+        return $info;
+    }
+}

+ 80 - 70
src/place/order/lib/Role/Pay.php

@@ -1,71 +1,81 @@
-<?php namespace Place_order\Lib\Role;
-use Dever;
-use Place;
-use Place_order\Lib\Pay as Core;
-class Pay extends Core
-{
-    protected $type = 'role';
-
-    # 获取明细
-    protected function getDetail($info)
-    {
-        $this->order['type'] = $info['type'];
-        $this->order['type_id'] = $info['id'];
-        $this->order['name'] = $info['name'];
-        $this->order['cash'] = $info['price'];
-        $this->order['num'] = 1;
-        $this->order['coupon_type'] = '2,' . $info['type'];
-        $this->order['coupon_type_id'] = $info['id'];
-
-        $this->detail[] = $this->order;
-    }
-
-    # 验证
-    protected function check(){}
-    # 下单成功
-    protected function success(){}
-    # 支付回调
-    protected function callback($order, $status)
-    {
-        if ($status == 1) {
-            $update['status'] = 2;
-        } else {
-            $update['status'] = 3;
-        }
-        
-        $update['pdate'] = time();
-        $state = Dever::db('role', 'place_order')->update($order['id'], $update);
-        if (!$state) {
-            return '订单更新失败';
-        }
-        if ($status == 1) {
-            $data = array('uid' => $order['uid'], 'type' => $order['type']);
-            $user = Dever::db('role', 'place_user')->find($data);
-            if ($order['type'] == 1) {
-                $table = 'vip';
-            } elseif ($order['type'] == 2) {
-                $table = 'saler';
-            } elseif ($order['type'] == 3) {
-                $table = 'agent';
-            }
-            $info = Dever::db($table, 'place')->find($order['type_id']);
-            if ($info) {
-                $data['type_id'] = $order['type_id'];
-                $data['edate'] = $info['day']*86400;
-                $date = time();
-                if ($user) {
-                    if ($user['status'] == 2 || $user['edate'] <= $date) {
-                        $data['edate'] += $date;
-                    } else {
-                        $data['edate'] += $user['edate'];
-                    }
-                    Dever::db('role', 'place_user')->update($user['id'], $data);
-                } else {
-                    $data['edate'] += $date;
-                    Dever::db('role', 'place_user')->insert($data);
-                }
-                Dever::db('info', 'place_user')->update($order['uid'], [$table . '_id' => $info['id']]);
-            }
-        }
-    }
+<?php namespace Place_order\Lib\Role;
+use Dever;
+use Place;
+use Place_order\Lib\Pay as Core;
+class Pay extends Core
+{
+    protected $type = 'role';
+
+    # 获取明细
+    protected function getDetail($info)
+    {
+        $level = Dever::db('level', 'place_role')->find(['id' => $info['id'], 'status' => 1], ['col' => 'id,info_id,name,info,level,price,day']);
+        if (!$level) {
+            Dever::error('等级不存在');
+        }
+        if ($this->set['id'] != $level['info_id']) {
+            Dever::error('等级不存在');
+        }
+
+        if ($this->set['user'] && $this->set['user']['level_id'] > 0 && $level['id'] != $this->set['user']['level_id'] && $level['pay'] == 1) {
+            $level['price'] -= $this->set['user']['price'];
+        }
+        $level['price_text'] = Dever::load('info', 'place_score')->getText($level['price'], $this->set['score']);
+
+        $this->detail[] = [
+            'pic' => Place::$user['avatar'],
+            'role_id' => $level['info_id'],
+            'level_id' => $level['id'],
+            'level' => $level['level'],
+            'coupon_type' => '2,' . $level['info_id'],
+            'coupon_type_id' => $level['id'],
+            'name' => $level['name'],
+            'cash' => Dever::number($level['price']),
+            'cash_text' => $level['price_text'],
+            'num' => $info['num'],
+        ];
+        if (count($this->detail) < 3) {
+            $this->order['name'][$level['id']] = $level['name'];
+        }
+        $this->order['cash'] += $level['price'] * $info['num'];
+        $this->order['num'] += $info['num'];
+    }
+
+    # 验证
+    protected function check(){}
+    # 下单成功
+    protected function success($order_id)
+    {
+        Dever::load('role/log', 'place_order')->up(1, $this->order['uid'], $order_id, '下单成功');
+        foreach ($this->detail as $v) {
+            $v['order_id'] = $order_id;
+            Dever::db('role_detail', 'place_order')->insert($v);
+        }
+    }
+    # 支付回调
+    protected function callback($order, $status)
+    {
+        if ($status == 1) {
+            $update['status'] = 2;
+            $msg = '支付成功';
+        } else {
+            $update['status'] = 3;
+            $msg = '支付失败';
+        }
+        
+        $update['pdate'] = time();
+        $state = Dever::db('role', 'place_order')->update($order['id'], $update);
+        if (!$state) {
+            return '订单更新失败';
+        }
+        Dever::load('role/log', 'place_order')->up(1, $order['uid'], $order['id'], $msg);
+        if ($status == 1) {
+            $detail = Dever::db('role_detail', 'place_order')->select(['order_id' => $order['id']], ['order' => 'level asc']);
+            if ($detail) {
+                foreach ($detail as $v) {
+                    Dever::load('user', 'place_role')->up($order['uid'], $v['role_id'], $v['level_id']);
+                }
+            }
+        }
+    }
 }

+ 3 - 3
src/place/order/lib/Source/Cart.php

@@ -7,7 +7,7 @@ class Cart
     public function getList()
     {
         $where['uid'] = Place::$uid;
-        $set = array();
+        $set = [];
         //$set['num'] = 100;
         $data = Dever::db('source_cart', 'place_order')->select($where, $set);
         if ($data) {
@@ -76,7 +76,7 @@ class Cart
         $data['sku_id'] = $sku_id;
         $info = Dever::db('source_cart', 'place_order')->find($data);
         if ($info) {
-            Dever::db('source_cart', 'place_order')->update($info['id'], array('status' => $status));
+            Dever::db('source_cart', 'place_order')->update($info['id'], ['status' => $status]);
         }
         return $this->getList();
     }
@@ -105,7 +105,7 @@ class Cart
         $where['status'] = 1;
         $data = Dever::db('source_cart', 'place_order')->select($where);
         if ($data) {
-            $result = array();
+            $result = [];
             $result['value'] = 0;
             $result['original'] = 0;
             $result['text'] = '';

+ 104 - 104
src/place/order/lib/Source/Express.php

@@ -1,105 +1,105 @@
-<?php namespace Place_order\Lib\Source;
-use Dever;
-use Place;
-class Express
-{
-    public function up($id, $order_id, $express_id, $number, $log = false)
-    {
-        $update['order_id'] = $order_id;
-        $update['express_id'] = $express_id;
-        $update['number'] = $number;
-        if ($id) {
-            $express = Dever::db('source_express', 'place_order')->find($id);
-            if ($express) {
-                Dever::db('source_express', 'place_order')->update($express['id'], $update);
-            }
-        } else {
-            Dever::db('source_express', 'place_order')->insert($update);
-            Dever::db('source', 'place_order')->update($order_id, array('status' => 3, 'ddate' => time()));
-        }
-        if ($log) {
-            $type = $log['type'];
-            $uid = $log['uid'];
-            $express_info = Dever::db('express', 'sector')->find($update['express_id']);
-            $msg = '已发货:' . $express_info['name'] . ',' . $update['number'];
-            Dever::load('source/log', 'place_order')->up($type, $uid, $order_id, $msg);
-        }
-    }
-
-    # 获取快递物流信息
-    public function getInfo($order, $address_id, $type = 1)
-    {
-        if ($type == 1) {
-            $info = Dever::db('source_express', 'place_order')->find(array('order_id' => $order['id']));
-        } else {
-            $info = Dever::db('source_refund_express', 'place_order')->find(array('order_refund_id' => $order['id']));
-        }
-
-        if ($info) {
-            $express_info = Dever::db('express', 'sector')->find($info['express_id']);
-            $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
-            $info['name'] = $express_info['name'];
-            $log = Dever::db('express_log', 'sector')->find(array('number' => $info['number']));
-            if ($log) {
-                if ($log['status'] == 1) {
-                    $info['log'] = Dever::json_decode($log['content']);
-                } else {
-                    if (time() - $log['udate'] > 3600) {
-                        list($info['log'], $order['status']) = $this->get($order, $info['express_id'], $info['number'], $log['mobile'], $log['id'], $type);
-                    } else {
-                        $info['log'] = Dever::json_decode($log['content']);
-                    }
-                }
-            } else {
-                $address = Dever::db('address', 'place_user')->find($address_id);
-                list($info['log'], $order['status']) = $this->get($order, $info['express_id'], $info['number'], $address['phone'], false, $type);
-            }
-            $order['express'] = $info;
-        }
-        return $order;
-    }
-
-    public function get($order, $express_id, $number, $mobile, $id = false, $type = 1)
-    {
-        $param['number'] = $number;
-        $param['mobile'] = substr($mobile, -4);
-        #$data = Dever::load('account', 'api')->run('aliyun_market', 'express', $param);
-        $data['data']['list'] = array();
-        $data['data']['state'] = 3;
-        if ($data && isset($data['data']['list'])) {
-            if ($data['data']['state'] == 3) {
-                $param['status'] = 1;
-                if ($type == 1) {
-                    if ($order['status'] <= 3) {
-                        if ($data['data']['list']) {
-                            $info = $data['data']['list'][0];
-                            Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], $info['status']);
-                        } else {
-                            $info['time'] = date('Y-m-d H:i:s', time());
-                        }
-                        $order['status'] = 4;
-                        Dever::db('source', 'place_order')->update($order['id'], array('status' => $order['status'], 'qdate' => strtotime($info['time'])));
-                    }
-                } else {
-                    if ($order['status'] <= 3) {
-                        $order_info = Dever::db('source', 'place_order')->find($order['order_id']);
-                        Dever::load('source/refund', 'place_order')->finish($order_info, $order);
-                    }
-                }
-                
-            } else {
-                $param['status'] = 2;
-            }
-            $param['content'] = Dever::json_encode($data['data']['list']);
-            $param['express_id'] = $express_id;
-            $param['udate'] = time();
-            if ($id) {
-                Dever::db('express_log', 'sector')->update($id, $param);
-            } else {
-                Dever::db('express_log', 'sector')->insert($param);
-            }
-            return array($data['data']['list'], $order['status']);
-        }
-        return array(array(), $order['status']);
-    }
+<?php namespace Place_order\Lib\Source;
+use Dever;
+use Place;
+class Express
+{
+    public function up($id, $order_id, $express_id, $number, $log = false)
+    {
+        $update['order_id'] = $order_id;
+        $update['express_id'] = $express_id;
+        $update['number'] = $number;
+        if ($id) {
+            $express = Dever::db('source_express', 'place_order')->find($id);
+            if ($express) {
+                Dever::db('source_express', 'place_order')->update($express['id'], $update);
+            }
+        } else {
+            Dever::db('source_express', 'place_order')->insert($update);
+            Dever::db('source', 'place_order')->update($order_id, ['status' => 3, 'ddate' => time()]);
+        }
+        if ($log) {
+            $type = $log['type'];
+            $uid = $log['uid'];
+            $express_info = Dever::db('express', 'sector')->find($update['express_id']);
+            $msg = '已发货:' . $express_info['name'] . ',' . $update['number'];
+            Dever::load('source/log', 'place_order')->up($type, $uid, $order_id, $msg);
+        }
+    }
+
+    # 获取快递物流信息
+    public function getInfo($order, $address_id, $type = 1)
+    {
+        if ($type == 1) {
+            $info = Dever::db('source_express', 'place_order')->find(['order_id' => $order['id']]);
+        } else {
+            $info = Dever::db('source_refund_express', 'place_order')->find(['order_refund_id' => $order['id']]);
+        }
+
+        if ($info) {
+            $express_info = Dever::db('express', 'sector')->find($info['express_id']);
+            $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
+            $info['name'] = $express_info['name'];
+            $log = Dever::db('express_log', 'sector')->find(['number' => $info['number']]);
+            if ($log) {
+                if ($log['status'] == 1) {
+                    $info['log'] = Dever::json_decode($log['content']);
+                } else {
+                    if (time() - $log['udate'] > 3600) {
+                        list($info['log'], $order['status']) = $this->get($order, $info['express_id'], $info['number'], $log['mobile'], $log['id'], $type);
+                    } else {
+                        $info['log'] = Dever::json_decode($log['content']);
+                    }
+                }
+            } else {
+                $address = Dever::db('address', 'place_user')->find($address_id);
+                list($info['log'], $order['status']) = $this->get($order, $info['express_id'], $info['number'], $address['phone'], false, $type);
+            }
+            $order['express'] = $info;
+        }
+        return $order;
+    }
+
+    public function get($order, $express_id, $number, $mobile, $id = false, $type = 1)
+    {
+        $param['number'] = $number;
+        $param['mobile'] = substr($mobile, -4);
+        #$data = Dever::load('account', 'api')->run('aliyun_market', 'express', $param);
+        $data['data']['list'] = [];
+        $data['data']['state'] = 3;
+        if ($data && isset($data['data']['list'])) {
+            if ($data['data']['state'] == 3) {
+                $param['status'] = 1;
+                if ($type == 1) {
+                    if ($order['status'] <= 3) {
+                        if ($data['data']['list']) {
+                            $info = $data['data']['list'][0];
+                            Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], $info['status']);
+                        } else {
+                            $info['time'] = date('Y-m-d H:i:s', time());
+                        }
+                        $order['status'] = 4;
+                        Dever::db('source', 'place_order')->update($order['id'], ['status' => $order['status'], 'qdate' => strtotime($info['time'])]);
+                    }
+                } else {
+                    if ($order['status'] <= 3) {
+                        $order_info = Dever::db('source', 'place_order')->find($order['order_id']);
+                        Dever::load('source/refund', 'place_order')->finish($order_info, $order);
+                    }
+                }
+                
+            } else {
+                $param['status'] = 2;
+            }
+            $param['content'] = Dever::json_encode($data['data']['list']);
+            $param['express_id'] = $express_id;
+            $param['udate'] = time();
+            if ($id) {
+                Dever::db('express_log', 'sector')->update($id, $param);
+            } else {
+                Dever::db('express_log', 'sector')->insert($param);
+            }
+            return [$data['data']['list'], $order['status']];
+        }
+        return [[], $order['status']];
+    }
 }

+ 1 - 1
src/place/order/lib/Source/Log.php

@@ -15,7 +15,7 @@ class Log
     # 获取日志信息
     public function getList($order_id)
     {
-        $log = Dever::db('source_log', 'place_order')->select(array('order_id' => $order_id));
+        $log = Dever::db('source_log', 'place_order')->select(['order_id' => $order_id]);
         if ($log) {
             foreach ($log as &$v) {
                 $v = $this->getInfo($v);

+ 262 - 276
src/place/order/lib/Source/Order.php

@@ -1,277 +1,263 @@
-<?php namespace Place_order\Lib\Source;
-use Dever;
-use Place;
-class Order
-{
-    # 获取订单信息
-    public function getInfo($info, $view = false)
-    {
-        if ($info['status'] == 1) {
-            $m = 3600;
-            # 支付倒计时
-            $info['time'] = time() - $info['cdate'];
-            if ($info['time'] >= $m) {
-                # 已过期,自动取消
-                $info['time'] = -1;
-                $this->cancel($info);
-                $info['status'] = 9;
-            } else {
-                $info['time'] = $m - $info['time'];
-            }
-        }
-        $info['scash'] = $info['cash'];
-        $info['cash'] = $info['cash'];
-        $info['detail'] = $this->getDetail($info['id']);
-        $info['info'] = '共' . intval($info['num']) . '件商品';
-        if ($view) {
-            $this->getView($info);
-        }
-        return $info;
-    }
-
-    # 获取订单里每个商品
-    public function getDetail($id)
-    {
-        $result = Dever::db('source_detail', 'place_order')->select(array('order_id' => $id), array('col' => 'id,name,pic,sku_name,sku_id,cash,num'));
-        if ($result) {
-            foreach ($result as &$v) {
-                $v['cash'] = Dever::load('price', 'place')->getText($v['cash'], 3);
-            }
-        }
-        return $result;
-    }
-
-    # 获取订单详情
-    public function getView(&$info)
-    {
-        # 收货地址
-        if ($info['address_id']) {
-            $info['address'] = Dever::load('address', 'place_user')->getInfo($info['address_id'], $info['uid']);
-        }
-        if (in_array($info['status'], array(3,4,5))) {
-            $info = Dever::load('source/express', 'place_order')->getInfo($info, $info['address_id']);
-            $info['status_name'] = Dever::db('source', 'place_order')->value('status', $info['status']);
-        }
-        $info['status_list'] = array
-        (
-            1 => array
-            (
-                'selected' => false,
-                'name' => '待付款',
-                'time' => $info['cdate_str'],
-            ),
-            2 => array
-            (
-                'selected' => false,
-                'name' => '待发货',
-                'time' => $info['pdate_str'] ?? '',
-            ),
-            3 => array
-            (
-                'selected' => false,
-                'name' => '待签收',
-                'time' => $info['ddate_str'] ?? '',
-            ),
-            4 => array
-            (
-                'selected' => false,
-                'name' => '待收货',
-                'time' => $info['qdate_str'] ?? '',
-            ),
-            5 => array
-            (
-                'selected' => false,
-                'name' => '已完成',
-                'time' => $info['fdate_str'] ?? '',
-            ),
-        );
-        foreach ($info['status_list'] as $k => &$status_list) {
-            if ($info['status'] >= $k) {
-                $status_list['selected'] = true;
-            }
-        }
-        if ($info['status'] == 1) {
-            $info['status_msg'] = '下单成功,待支付';
-        } elseif ($info['status'] == 2) {
-            $info['status_msg'] = '支付成功,待发货';
-        } elseif ($info['status'] == 3) {
-            $info['status_msg'] = '配送中,等待签收';
-        } elseif ($info['status'] == 4) {
-            $info['status_msg'] = '已签收,等待确认';
-        } elseif ($info['status'] == 5 || $info['status'] == 6) {
-            $info['status_msg'] = '订单已完成';
-        } elseif ($info['status'] > 6) {
-            $info['status_msg'] = '订单已取消';
-        }
-        
-        $info['refund'] = false;
-        $info['refund_list'] = Dever::db('source_refund', 'place_order')->select(array('order_id' => $info['id']));
-        if ($info['refund_list']) {
-            foreach ($info['refund_list'] as $k => $v) {
-                if ($v['status'] < 4) {
-                    $info['refund'] = $v;
-                }
-            }
-        }
-        if ($info['refund']) {
-            if ($info['refund']['status'] > 2) {
-                $info['refund'] = Dever::load('source/express', 'place_order')->getInfo($info['refund'], $info['address_id'], 2);
-            }
-            $info['refund']['cdate_str'] = date('Y-m-d H:i:s', $info['refund']['cdate']);
-            if (isset($info['refund']['sdate']) && $info['refund']['sdate']) {
-                $info['refund']['sdate_str'] = date('Y-m-d H:i:s', $info['refund']['sdate']);
-            }
-            if (isset($info['refund']['ddate']) && $info['refund']['ddate']) {
-                $info['refund']['ddate_str'] = date('Y-m-d H:i:s', $info['refund']['ddate']);
-            }
-            if (isset($info['refund']['fdate']) && $info['refund']['fdate']) {
-                $info['refund']['fdate_str'] = date('Y-m-d H:i:s', $info['refund']['fdate']);
-            }
-            if ($info['refund']['type'] == 1) {
-                $info['refund_status_list'] = array
-                (
-                    1 => array
-                    (
-                        'selected' => false,
-                        'name' => '退货退款',
-                        'time' => $info['refund']['cdate_str'],
-                    ),
-                    2 => array
-                    (
-                        'selected' => false,
-                        'name' => '已审核',
-                        'time' => $info['refund']['sdate_str'] ?? '',
-                    ),
-                    3 => array
-                    (
-                        'selected' => false,
-                        'name' => '买家已发货',
-                        'time' => $info['refund']['ddate_str'] ?? '',
-                    ),
-                    4 => array
-                    (
-                        'selected' => false,
-                        'name' => '已完成',
-                        'time' => $info['refund']['fdate_str'] ?? '',
-                    ),
-                );
-            }
-            if ($info['refund']['type'] == 2) {
-                $info['refund_status_list'] = array
-                (
-                    1 => array
-                    (
-                        'selected' => false,
-                        'name' => '仅退款',
-                        'time' => $info['cdate_str'],
-                    ),
-                    2 => array
-                    (
-                        'selected' => false,
-                        'name' => '已审核',
-                        'time' => $info['sdate_str'] ?? '',
-                    ),
-                    4 => array
-                    (
-                        'selected' => false,
-                        'name' => '已完成',
-                        'time' => $info['fdate_str'] ?? '',
-                    ),
-                );
-            }
-            foreach ($info['refund_status_list'] as $k => $v) {
-                if ($info['refund']['status'] >= $k) {
-                    $info['refund_status_list'][$k]['selected'] = true;
-                }
-            }
-        }
-    }
-
-    # 取消订单
-    public function cancel($order, $status = 9)
-    {
-        if ($order['status'] == 1) {
-            $state = Dever::db('source', 'place_order')->update($order['id'], array('status' => $status, 'fdate' => time()));
-            if ($state) {
-                # 恢复库存
-                $this->resell($order['id']);
-            }
-            return 'ok';
-        }
-    }
-
-    # 支付成功
-    public function success($order, $status)
-    {
-        if ($status == 1) {
-            $update['status'] = 2;
-            $msg = '支付成功';
-            
-        } else {
-            $update['status'] = 7;
-            $msg = '支付失败';
-        }
-        $update['pdate'] = time();
-        $state = Dever::db('source', 'place_order')->update($order['id'], $update);
-        Dever::load('source/log', 'place_order')->up(1, $order['uid'], $data['order_id'], $msg);
-        if ($state && $update['status'] == 7) {
-            # 恢复库存
-            $this->resell($order['id']);
-        }
-        return $state;
-    }
-
-    # 确认收货
-    public function finish_commit(){}
-    public function finish($type = 1, $order, $yes = false)
-    {
-        if ($yes || ($order['status'] >= 3 && $order['status'] <= 6)) {
-            if ($type == 1) {
-                $uid = $order['uid'];
-            } else {
-                $uid = '';
-            }
-            # 检查有没有退款
-            $refund = Dever::db('source_refund', 'place_order')->find(array('order_id' => $order['id'], 'refund_status' => 1));
-            $status = 5;
-            if ($refund) {
-                $status = 6;
-            }
-            Dever::db('source', 'place_order')->update($order['id'], array('status' => $status, 'fdate' => time()));
-            Dever::load('source/log', 'place_order')->up($type, $uid, $order['id'], '确认收货,订单完成');
-
-            # 增加次数
-            if ($status) {
-                $detail = Dever::db('source_detail', 'place_order')->select(array('order_id' => $order['id']));
-                if ($detail) {
-                    foreach ($detail as $k => $v) {
-                        $refund_detail = Dever::db('source_refund_detail', 'place_order')->select(array('detail_id' => $v['id'], 'refund_status' => 1));
-                        $unum = $v['unum'];
-                        if ($refund_detail) {
-                            foreach ($refund_detail as $v1) {
-                                $unum -= $v1['num'];
-                            }
-                        }
-                        if ($unum > 0) {
-                            Dever::load('source/user', 'place_order')->up($order['uid'], $v['source_id'], $v['sku_id'], 1, $unum);
-                        }
-                    }
-                }
-
-                # 获取当前用户上级 增加佣金 获取实付款
-                //Dever::load('log', 'place_score')->add(Place::$uid, '推广', '购买');
-            }
-        }
-    }
-
-    # 恢复库存
-    public function resell($id)
-    {
-        $result = Dever::db('source_detail', 'place_order')->select(array('order_id' => $id));
-        if ($result) {
-            foreach ($result as $v) {
-                $state = Dever::load('stock', 'place_source')->sell($v['info_id'], $v['sku_id'], $v['num']*-1);
-            }
-        }  
-    }
+<?php namespace Place_order\Lib\Source;
+use Dever;
+use Place;
+class Order
+{
+    # 获取订单信息
+    public function getInfo($info, $view = false)
+    {
+        if ($info['status'] == 1) {
+            $m = 3600;
+            # 支付倒计时
+            $info['time'] = time() - $info['cdate'];
+            if ($info['time'] >= $m) {
+                # 已过期,自动取消
+                $info['time'] = -1;
+                $this->cancel($info);
+                $info['status'] = 9;
+            } else {
+                $info['time'] = $m - $info['time'];
+            }
+        }
+        $info['scash'] = $info['cash'];
+        $info['cash'] = $info['cash'];
+        $info['detail'] = $this->getDetail($info['id']);
+        $info['info'] = '共' . intval($info['num']) . '件商品';
+        if ($view) {
+            $this->getView($info);
+        }
+        return $info;
+    }
+
+    # 获取订单里每个商品
+    public function getDetail($id)
+    {
+        $result = Dever::db('source_detail', 'place_order')->select(['order_id' => $id], ['col' => 'id,name,pic,sku_name,sku_id,cash,num']);
+        if ($result) {
+            foreach ($result as &$v) {
+                $v['cash'] = Dever::load('price', 'place')->getText($v['cash'], 3);
+            }
+        }
+        return $result;
+    }
+
+    # 获取订单详情
+    public function getView($info)
+    {
+        # 收货地址
+        if ($info['address_id']) {
+            $info['address'] = Dever::load('address', 'place_user')->getInfo($info['address_id'], $info['uid']);
+        }
+        if (in_[$info['status'], [3,4,5]]) {
+            $info = Dever::load('source/express', 'place_order')->getInfo($info, $info['address_id']);
+            $info['status_name'] = Dever::db('source', 'place_order')->value('status', $info['status']);
+        }
+        $info['status_list'] = [
+            1 => [
+                'selected' => false,
+                'name' => '待付款',
+                'time' => $info['cdate_str'],
+            ],
+            2 => [
+                'selected' => false,
+                'name' => '待发货',
+                'time' => $info['pdate_str'] ?? '',
+            ],
+            3 => [
+                'selected' => false,
+                'name' => '待签收',
+                'time' => $info['ddate_str'] ?? '',
+            ],
+            4 => [
+                'selected' => false,
+                'name' => '待收货',
+                'time' => $info['qdate_str'] ?? '',
+            ],
+            5 => [
+                'selected' => false,
+                'name' => '已完成',
+                'time' => $info['fdate_str'] ?? '',
+            ],
+        ];
+        foreach ($info['status_list'] as $k => &$status_list) {
+            if ($info['status'] >= $k) {
+                $status_list['selected'] = true;
+            }
+        }
+        if ($info['status'] == 1) {
+            $info['status_msg'] = '下单成功,待支付';
+        } elseif ($info['status'] == 2) {
+            $info['status_msg'] = '支付成功,待发货';
+        } elseif ($info['status'] == 3) {
+            $info['status_msg'] = '配送中,等待签收';
+        } elseif ($info['status'] == 4) {
+            $info['status_msg'] = '已签收,等待确认';
+        } elseif ($info['status'] == 5 || $info['status'] == 6) {
+            $info['status_msg'] = '订单已完成';
+        } elseif ($info['status'] > 6) {
+            $info['status_msg'] = '订单已取消';
+        }
+        
+        $info['refund'] = false;
+        $info['refund_list'] = Dever::db('source_refund', 'place_order')->select(['order_id' => $info['id']]);
+        if ($info['refund_list']) {
+            foreach ($info['refund_list'] as $k => $v) {
+                if ($v['status'] < 4) {
+                    $info['refund'] = $v;
+                }
+            }
+        }
+        if ($info['refund']) {
+            if ($info['refund']['status'] > 2) {
+                $info['refund'] = Dever::load('source/express', 'place_order')->getInfo($info['refund'], $info['address_id'], 2);
+            }
+            $info['refund']['cdate_str'] = date('Y-m-d H:i:s', $info['refund']['cdate']);
+            if (isset($info['refund']['sdate']) && $info['refund']['sdate']) {
+                $info['refund']['sdate_str'] = date('Y-m-d H:i:s', $info['refund']['sdate']);
+            }
+            if (isset($info['refund']['ddate']) && $info['refund']['ddate']) {
+                $info['refund']['ddate_str'] = date('Y-m-d H:i:s', $info['refund']['ddate']);
+            }
+            if (isset($info['refund']['fdate']) && $info['refund']['fdate']) {
+                $info['refund']['fdate_str'] = date('Y-m-d H:i:s', $info['refund']['fdate']);
+            }
+            if ($info['refund']['type'] == 1) {
+                $info['refund_status_list'] = [
+                    1 => [
+                        'selected' => false,
+                        'name' => '退货退款',
+                        'time' => $info['refund']['cdate_str'],
+                    ],
+                    2 => [
+                        'selected' => false,
+                        'name' => '已审核',
+                        'time' => $info['refund']['sdate_str'] ?? '',
+                    ],
+                    3 => [
+                        'selected' => false,
+                        'name' => '买家已发货',
+                        'time' => $info['refund']['ddate_str'] ?? '',
+                    ],
+                    4 => [
+                        'selected' => false,
+                        'name' => '已完成',
+                        'time' => $info['refund']['fdate_str'] ?? '',
+                    ],
+                ];
+            }
+            if ($info['refund']['type'] == 2) {
+                $info['refund_status_list'] = [
+                    1 => [
+                        'selected' => false,
+                        'name' => '仅退款',
+                        'time' => $info['cdate_str'],
+                    ],
+                    2 => [
+                        'selected' => false,
+                        'name' => '已审核',
+                        'time' => $info['sdate_str'] ?? '',
+                    ],
+                    4 => [
+                        'selected' => false,
+                        'name' => '已完成',
+                        'time' => $info['fdate_str'] ?? '',
+                    ],
+                ];
+            }
+            foreach ($info['refund_status_list'] as $k => $v) {
+                if ($info['refund']['status'] >= $k) {
+                    $info['refund_status_list'][$k]['selected'] = true;
+                }
+            }
+        }
+        return $info;
+    }
+
+    # 取消订单
+    public function cancel($order, $status = 9)
+    {
+        if ($order['status'] == 1) {
+            $state = Dever::db('source', 'place_order')->update($order['id'], ['status' => $status, 'fdate' => time()]);
+            if ($state) {
+                # 恢复库存
+                $this->resell($order['id']);
+            }
+            return 'ok';
+        }
+    }
+
+    # 支付成功
+    public function success($order, $status)
+    {
+        if ($status == 1) {
+            $update['status'] = 2;
+            $msg = '支付成功';
+            
+        } else {
+            $update['status'] = 7;
+            $msg = '支付失败';
+        }
+        $update['pdate'] = time();
+        $state = Dever::db('source', 'place_order')->update($order['id'], $update);
+        Dever::load('source/log', 'place_order')->up(1, $order['uid'], $data['order_id'], $msg);
+        if ($state && $update['status'] == 7) {
+            # 恢复库存
+            $this->resell($order['id']);
+        }
+        return $state;
+    }
+
+    # 确认收货
+    public function finish_commit(){}
+    public function finish($type = 1, $order, $yes = false)
+    {
+        if ($yes || ($order['status'] >= 3 && $order['status'] <= 6)) {
+            if ($type == 1) {
+                $uid = $order['uid'];
+            } else {
+                $uid = '';
+            }
+            # 检查有没有退款
+            $refund = Dever::db('source_refund', 'place_order')->find(['order_id' => $order['id'], 'refund_status' => 1]);
+            $status = 5;
+            if ($refund) {
+                $status = 6;
+            }
+            Dever::db('source', 'place_order')->update($order['id'], ['status' => $status, 'fdate' => time()]);
+            Dever::load('source/log', 'place_order')->up($type, $uid, $order['id'], '确认收货,订单完成');
+
+            # 增加次数
+            if ($status) {
+                $detail = Dever::db('source_detail', 'place_order')->select(['order_id' => $order['id']]);
+                if ($detail) {
+                    foreach ($detail as $k => $v) {
+                        $refund_detail = Dever::db('source_refund_detail', 'place_order')->select(['detail_id' => $v['id'], 'refund_status' => 1]);
+                        $unum = $v['unum'];
+                        if ($refund_detail) {
+                            foreach ($refund_detail as $v1) {
+                                $unum -= $v1['num'];
+                            }
+                        }
+                        if ($unum > 0) {
+                            Dever::load('source/user', 'place_order')->up($order['uid'], $v['source_id'], $v['sku_id'], 1, $unum);
+                        }
+                    }
+                }
+
+                # 获取当前用户上级 增加佣金 获取实付款
+                //Dever::load('log', 'place_score')->add(Place::$uid, '推广', '购买');
+            }
+        }
+    }
+
+    # 恢复库存
+    public function resell($id)
+    {
+        $result = Dever::db('source_detail', 'place_order')->select(['order_id' => $id]);
+        if ($result) {
+            foreach ($result as $v) {
+                $state = Dever::load('stock', 'place_source')->sell($v['info_id'], $v['sku_id'], $v['num']*-1);
+            }
+        }  
+    }
 }

+ 115 - 112
src/place/order/lib/Source/Pay.php

@@ -1,113 +1,116 @@
-<?php namespace Place_order\Lib\Source;
-use Dever;
-use Place;
-use Place_order\Lib\Pay as Core;
-class Pay extends Core
-{
-    protected $type = 'source';
-    # 获取明细
-    protected function getDetail($info)
-    {
-        $source = Dever::db('info', 'place_source')->find(array('id' => $info['id']), array('col' => 'id,name,pic,cate_id,channel_id,cate_parent_id,type,have_vip'));
-        if (!$source) {
-            Dever::error('资源不存在');
-        }
-        $sku = Dever::load('sku', 'api')->getList(array('info_id' => $source['id']), $info['sku_id'], 'place_source');
-        if ($sku['info']) {
-            $cate = Dever::load('cate', 'place_source')->getInfo($source['cate_id']);
-            $sku = Dever::load('price', 'place_source')->get($sku['info'], $cate, $info['num']);
-        } else {
-            Dever::error('规格不存在');
-        }
-        $have = Dever::load('price', 'place_source')->getHave($source);
-        if ($have['status'] != 1) {
-            Dever::error('专享资源无法购买');
-        }
-        
-        if (!$sku['pic']) {
-            $source['pic'] = explode(',', $source['pic']);
-            $sku['pic'] = $source['pic'][0];
-        }
-
-        $this->detail[] = array
-        (
-            'source_id' => $source['id'],
-            'sku_id' => $sku['id'],
-            'coupon_type' => '1,'.$source['channel_id'].','.$source['cate_parent_id'],
-            'coupon_type_id' => $source['id'],
-            'name' => $source['name'],
-            'sku_name' => $sku['name'],
-            'pic' => $sku['pic'],
-            'cash' => Dever::number($sku['price']),
-            'num' => $sku['buy_num'],
-            'unum' => $sku['unum'],
-        );
-        if (count($this->detail) < 3) {
-            $this->order['name'][$source['id']] = $source['name'];
-        }
-        $this->order['cash'] += $sku['price'] * $sku['buy_num'];
-        $this->order['num'] += $sku['buy_num'];
-    }
-
-    # 下单成功
-    protected function success($order_id)
-    {
-        Dever::load('source/log', 'place_order')->up(1, $this->order['uid'], $order_id, '下单成功');
-        foreach ($this->detail as $v) {
-            $v['order_id'] = $order_id;
-            Dever::db('source_detail', 'place_order')->insert($v);
-        }
-    }
-
-    # 支付成功回调
-    protected function callback($order, $status)
-    {
-        if ($status == 1) {
-            $update['status'] = 2;
-            $msg = '支付成功';
-        } else {
-            $update['status'] = 7;
-            $msg = '支付失败';
-        }
-        $update['pdate'] = time();
-        $state = Dever::db('source', 'place_order')->update($order['id'], $update);
-        Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], $msg);
-        if ($state && $update['status'] == 7) {
-            # 恢复库存
-            $this->resell($order['id']);
-        } elseif ($state && $update['status'] == 2 && $order['source_type'] == 3) {
-            Dever::load('source/order', 'place_order')->finish(1, $order, true);
-        } else {
-            //Dever::load('log', 'place_score')->add(Place::$uid, '推广', '购买', 2);
-        }
-    }
-
-    # 验证库存
-    protected function check()
-    {
-        foreach ($this->detail as $v) {
-            $stock = Dever::load('stock', 'place_source')->yue($v['source_id'], $v['sku_id']);
-            if ($stock !== false) {
-                if ($stock < $v['num']) {
-                    Dever::error($v['name'] . '-' . $v['sku_name'] . '库存不足');
-                } else {
-                    $state = Dever::load('stock', 'place_source')->sell($v['source_id'], $v['sku_id'], $v['num']);
-                    if (!$state) {
-                        Dever::error('库存不足');
-                    }
-                }
-            }
-        }
-    }
-
-    # 恢复库存
-    protected function resell($id)
-    {
-        $result = Dever::db('source_detail', 'place_order')->select(array('order_id' => $id));
-        if ($result) {
-            foreach ($result as $v) {
-                $state = Dever::load('stock', 'place_source')->sell($v['source_id'], $v['sku_id'], $v['num']*-1);
-            }
-        }  
-    }
+<?php namespace Place_order\Lib\Source;
+use Dever;
+use Place;
+use Place_order\Lib\Pay as Core;
+class Pay extends Core
+{
+    protected $type = 'source';
+    # 获取明细
+    protected function getDetail($info)
+    {
+        $source = Dever::db('info', 'place_source')->find(['id' => $info['id']], ['col' => 'id,name,pic,cate_id,channel_id,cate_parent_id,type,have_vip']);
+        if (!$source) {
+            Dever::error('资源不存在');
+        }
+        if ($this->set['id'] != $source['cate_id']) {
+            Dever::error('资源不存在');
+        }
+        $sku = Dever::load('sku', 'api')->getList(['info_id' => $source['id']], $info['sku_id'], 'place_source');
+        if (!$sku['info']) {
+            Dever::error('规格不存在');
+        }
+        $sku = Dever::load('price', 'place_source')->get($sku['info'], $this->set, $info['num']);
+        $have = Dever::load('price', 'place_source')->getHave($source);
+        if ($have['status'] != 1) {
+            Dever::error('专享资源无法购买');
+        }
+        
+        if (!$sku['pic']) {
+            $source['pic'] = explode(',', $source['pic']);
+            $sku['pic'] = $source['pic'][0];
+        }
+
+        $this->detail[] = [
+            'source_id' => $source['id'],
+            'sku_id' => $sku['id'],
+            'coupon_type' => '1,'.$source['channel_id'].','.$source['cate_parent_id'],
+            'coupon_type_id' => $source['id'],
+            'name' => $source['name'],
+            'sku_name' => $sku['name'],
+            'pic' => $sku['pic'],
+            'cash' => Dever::number($sku['price']),
+            'cash_text' => $sku['price_text'],
+            'num' => $sku['buy_num'],
+            'unum' => $sku['unum'],
+            'stock' => $sku['stock'],
+        ];
+        if (count($this->detail) < 3) {
+            $this->order['name'][$source['id']] = $source['name'];
+        }
+        if (empty($this->order['deliver_type'])) $source['type'];
+        $this->order['cash'] += $sku['price'] * $sku['buy_num'];
+        $this->order['num'] += $sku['buy_num'];
+    }
+
+    # 下单成功
+    protected function success($order_id)
+    {
+        Dever::load('source/log', 'place_order')->up(1, $this->order['uid'], $order_id, '下单成功');
+        foreach ($this->detail as $v) {
+            $v['order_id'] = $order_id;
+            Dever::db('source_detail', 'place_order')->insert($v);
+        }
+    }
+
+    # 支付成功回调
+    protected function callback($order, $status)
+    {
+        if ($status == 1) {
+            $update['status'] = 2;
+            $msg = '支付成功';
+        } else {
+            $update['status'] = 7;
+            $msg = '支付失败';
+        }
+        $update['pdate'] = time();
+        $state = Dever::db('source', 'place_order')->update($order['id'], $update);
+        Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], $msg);
+        if ($state && $update['status'] == 7) {
+            # 恢复库存
+            $this->resell($order['id']);
+        } elseif ($state && $update['status'] == 2 && $order['source_type'] == 3) {
+            Dever::load('source/order', 'place_order')->finish(1, $order, true);
+        } else {
+            //Dever::load('log', 'place_score')->add(Place::$uid, '推广', '购买', 2);
+        }
+    }
+
+    # 验证库存
+    protected function check()
+    {
+        foreach ($this->detail as $v) {
+            $stock = Dever::load('stock', 'place_source')->yue($v['source_id'], $v['sku_id']);
+            if ($stock !== false) {
+                if ($stock < $v['num']) {
+                    Dever::error($v['name'] . '-' . $v['sku_name'] . '库存不足');
+                } else {
+                    $state = Dever::load('stock', 'place_source')->sell($v['source_id'], $v['sku_id'], $v['num']);
+                    if (!$state) {
+                        Dever::error('库存不足');
+                    }
+                }
+            }
+        }
+    }
+
+    # 恢复库存
+    protected function resell($id)
+    {
+        $result = Dever::db('source_detail', 'place_order')->select(['order_id' => $id]);
+        if ($result) {
+            foreach ($result as $v) {
+                $state = Dever::load('stock', 'place_source')->sell($v['source_id'], $v['sku_id'], $v['num']*-1);
+            }
+        }  
+    }
 }

+ 142 - 142
src/place/order/lib/Source/Refund.php

@@ -1,143 +1,143 @@
-<?php namespace Place_order\Lib\Source;
-use Dever;
-use Place;
-class Refund
-{
-    # 买家发货
-    public function express($order, $refund, $express_id, $number)
-    {
-        $refund = Dever::db('source_refund', 'place_order')->find($refund['id']);
-        if ($refund['status'] == 2) {
-            $update['status'] = 3;
-            $update['ddate'] = time();
-            $where = array('source_refund_id' => $refund['id']);
-            $info = Dever::db('source_refund_express', 'place_order')->find($where);
-            if (!$info) {
-                $where['order_id'] = $order['id'];
-                $where['express_id'] = $express_id;
-                $where['number'] = $number;
-                Dever::db('source_refund_express', 'place_order')->insert($where);
-                Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], '退款:买家已发货');
-            }
-            Dever::db('source_refund', 'place_order')->update($refund['id'], $update);
-        }
-    }
-
-    # 完成退款 如果是支付订单,原路退回
-    public function finish($order, $refund)
-    {
-        $refund = Dever::db('source_refund', 'place_order')->find($refund['id']);
-        if ($refund['status'] == 2 || $refund['status'] == 3) {
-            $update['status'] = 4;
-            $update['fdate'] = time();
-            $update['refund_status'] = 1;
-            Dever::db('source_refund', 'place_order')->update($refund['id'], $update);
-            Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], '退款:已完成退款');
-
-            # 检测订单是否全都退了
-            $refund = Dever::db('source_refund', 'place_order')->select(array('order_id' => $order['id']));
-            $cash = 0;
-            foreach ($refund as $k => $v) {
-                $cash += $v['cash'];
-            }
-
-            if ($cash >= $order['cash']) {
-                $refund = Dever::db('source', 'place_order')->update($order['id'], array('status' => 8, 'fdate' => time(), 'refund_status' => 2));
-
-                Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], '订单已退款');
-                # 恢复库存
-                Dever::load('source', 'place_order')->resell($order['id']);
-            }
-
-            # 判断是否支付订单,如果是,走退款流程
-            if ($order['type'] == 1) {
-
-            }
-        }
-    }
-
-    public function up($detail, $order, $type, $desc_type, $cash, $desc, $log = false)
-    {
-        if ($detail) {
-            foreach ($detail as $k => $v) {
-                $info = Dever::db('source_detail', 'place_order')->find($v['detail_id']);
-                $refund = Dever::db('source_refund_detail', 'place_order')->find(array('detail_id' => $v['detail_id'], 'refund_status' => 1), array('col' => 'sum(num) as num'));
-                if ($refund && $refund['num']) {
-                    $info['num'] -= $refund['num'];
-                }
-                if ($v['num'] > $info['num']) {
-                    Dever::error('退款数量不能大于下单商品数量');
-                }
-            }
-        }
-        $where = array('order_id' => $order['id'], 'refund_status' => 1);
-        $refund = Dever::db('source_refund', 'place_order')->find($where, array('col' => 'sum(cash) as cash'));
-        if ($refund && $refund['cash']) {
-            $order['cash'] -= $refund['cash'];
-        }
-        if ($cash > $order['cash']) {
-            Dever::error('退款金额不能大于订单金额');
-        }
-        $update = $where;
-        $update['refund_status'] = 2;
-        $update['status'] = array('<', '5');
-        $refund = Dever::db('source_refund', 'place_order')->find($update);
-        $update['type'] = $type;
-        $update['desc_type'] = $desc_type;
-        $update['cash'] = $cash;
-        $update['desc'] = $desc;
-        $update['status'] = 1;
-        if ($refund) {
-            Dever::error('您有退款进行中,请先处理');
-        } else {
-            $id = Dever::db('source_refund', 'place_order')->insert($update);
-            if ($id) {
-                Dever::db('source', 'place_order')->update($order['id'], array('refund_status' => 1));
-                if ($detail) {
-                    foreach ($detail as $k => $v) {
-                        $v['source_refund_id'] = $id;
-                        Dever::db('source_refund_detail', 'place_order')->insert($v);
-                    }
-                }
-                if ($log) {
-                    $type = $log['type'];
-                    $uid = $log['uid'];
-                    $msg = '退款:提交退款申请单';
-                    Dever::load('source/log', 'place_order')->up($type, $uid, $order['id'], $msg);
-                }
-            }
-        }
-    }
-
-    # 获取信息
-    public function getList($order_id)
-    {
-        $refund = Dever::db('source_refund', 'place_order')->select(array('order_id' => $order_id));
-        if ($refund) {
-            foreach ($refund as &$v) {
-                $v = $this->getInfo($v);
-            }
-        }
-        return $refund;
-    }
-
-    # 获取信息
-    public function getInfo($info)
-    {
-        print_r($info);die;
-        if ($info['type'] == 1) {
-            $user = Dever::db('info', 'place_user')->find($info['type_id']);
-        } elseif ($info['type'] == 2) {
-            $user = Dever::db('user', 'sector')->find($info['type_id']);
-        } elseif ($info['type'] == 3) {
-            $user = Dever::db('supplier', 'place')->find($info['type_id']);
-        } else {
-            $user['name'] = $user['mobile'] = '-';
-        }
-        $info['type'] = Dever::db('source_log', 'place_order')->value('type', $info);
-        $info['name'] = $user['name'];
-        $info['mobile'] = $user['mobile'];
-        $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
-        return $info;
-    }
+<?php namespace Place_order\Lib\Source;
+use Dever;
+use Place;
+class Refund
+{
+    # 买家发货
+    public function express($order, $refund, $express_id, $number)
+    {
+        $refund = Dever::db('source_refund', 'place_order')->find($refund['id']);
+        if ($refund['status'] == 2) {
+            $update['status'] = 3;
+            $update['ddate'] = time();
+            $where = ['source_refund_id' => $refund['id']];
+            $info = Dever::db('source_refund_express', 'place_order')->find($where);
+            if (!$info) {
+                $where['order_id'] = $order['id'];
+                $where['express_id'] = $express_id;
+                $where['number'] = $number;
+                Dever::db('source_refund_express', 'place_order')->insert($where);
+                Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], '退款:买家已发货');
+            }
+            Dever::db('source_refund', 'place_order')->update($refund['id'], $update);
+        }
+    }
+
+    # 完成退款 如果是支付订单,原路退回
+    public function finish($order, $refund)
+    {
+        $refund = Dever::db('source_refund', 'place_order')->find($refund['id']);
+        if ($refund['status'] == 2 || $refund['status'] == 3) {
+            $update['status'] = 4;
+            $update['fdate'] = time();
+            $update['refund_status'] = 1;
+            Dever::db('source_refund', 'place_order')->update($refund['id'], $update);
+            Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], '退款:已完成退款');
+
+            # 检测订单是否全都退了
+            $refund = Dever::db('source_refund', 'place_order')->select(['order_id' => $order['id']]);
+            $cash = 0;
+            foreach ($refund as $k => $v) {
+                $cash += $v['cash'];
+            }
+
+            if ($cash >= $order['cash']) {
+                $refund = Dever::db('source', 'place_order')->update($order['id'], ['status' => 8, 'fdate' => time(), 'refund_status' => 2]);
+
+                Dever::load('source/log', 'place_order')->up(1, $order['uid'], $order['id'], '订单已退款');
+                # 恢复库存
+                Dever::load('source', 'place_order')->resell($order['id']);
+            }
+
+            # 判断是否支付订单,如果是,走退款流程
+            if ($order['type'] == 1) {
+
+            }
+        }
+    }
+
+    public function up($detail, $order, $type, $desc_type, $cash, $desc, $log = false)
+    {
+        if ($detail) {
+            foreach ($detail as $k => $v) {
+                $info = Dever::db('source_detail', 'place_order')->find($v['detail_id']);
+                $refund = Dever::db('source_refund_detail', 'place_order')->find(['detail_id' => $v['detail_id'], 'refund_status' => 1], ['col' => 'sum(num) as num']);
+                if ($refund && $refund['num']) {
+                    $info['num'] -= $refund['num'];
+                }
+                if ($v['num'] > $info['num']) {
+                    Dever::error('退款数量不能大于下单商品数量');
+                }
+            }
+        }
+        $where = ['order_id' => $order['id'], 'refund_status' => 1];
+        $refund = Dever::db('source_refund', 'place_order')->find($where, ['col' => 'sum(cash) as cash']);
+        if ($refund && $refund['cash']) {
+            $order['cash'] -= $refund['cash'];
+        }
+        if ($cash > $order['cash']) {
+            Dever::error('退款金额不能大于订单金额');
+        }
+        $update = $where;
+        $update['refund_status'] = 2;
+        $update['status'] = ['<', '5'];
+        $refund = Dever::db('source_refund', 'place_order')->find($update);
+        $update['type'] = $type;
+        $update['desc_type'] = $desc_type;
+        $update['cash'] = $cash;
+        $update['desc'] = $desc;
+        $update['status'] = 1;
+        if ($refund) {
+            Dever::error('您有退款进行中,请先处理');
+        } else {
+            $id = Dever::db('source_refund', 'place_order')->insert($update);
+            if ($id) {
+                Dever::db('source', 'place_order')->update($order['id'], ['refund_status' => 1]);
+                if ($detail) {
+                    foreach ($detail as $k => $v) {
+                        $v['source_refund_id'] = $id;
+                        Dever::db('source_refund_detail', 'place_order')->insert($v);
+                    }
+                }
+                if ($log) {
+                    $type = $log['type'];
+                    $uid = $log['uid'];
+                    $msg = '退款:提交退款申请单';
+                    Dever::load('source/log', 'place_order')->up($type, $uid, $order['id'], $msg);
+                }
+            }
+        }
+    }
+
+    # 获取信息
+    public function getList($order_id)
+    {
+        $refund = Dever::db('source_refund', 'place_order')->select(['order_id' => $order_id]);
+        if ($refund) {
+            foreach ($refund as &$v) {
+                $v = $this->getInfo($v);
+            }
+        }
+        return $refund;
+    }
+
+    # 获取信息
+    public function getInfo($info)
+    {
+        print_r($info);die;
+        if ($info['type'] == 1) {
+            $user = Dever::db('info', 'place_user')->find($info['type_id']);
+        } elseif ($info['type'] == 2) {
+            $user = Dever::db('user', 'sector')->find($info['type_id']);
+        } elseif ($info['type'] == 3) {
+            $user = Dever::db('supplier', 'place')->find($info['type_id']);
+        } else {
+            $user['name'] = $user['mobile'] = '-';
+        }
+        $info['type'] = Dever::db('source_log', 'place_order')->value('type', $info);
+        $info['name'] = $user['name'];
+        $info['mobile'] = $user['mobile'];
+        $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
+        return $info;
+    }
 }

+ 5 - 6
src/place/order/lib/Source/User.php

@@ -58,13 +58,12 @@ class User
     # 更新余额
     public function sync($uid, $source_id, $sku_id)
     {
-        $where = array
-        (
+        $where = [
             'uid' => $uid,
             'source_id' => $source_id,
             'sku_id' => $sku_id,
             'type' => 1,
-        );
+        ];
         $data['unum_total'] = Dever::db('user_source_log', 'place_order')->sum($where, 'amount');
         $where['type'] = 2;
         $data['unum_used'] = Dever::db('user_source_log', 'place_order')->sum($where, 'amount');
@@ -78,11 +77,11 @@ class User
         $info = Dever::db('user_source', 'place_order')->find($data);
         if (!$info) {
             $data['unum_total'] = $amount;
-            $data['unum_balance'] = array('unum_total', '-', 'unum_used');
+            $data['unum_balance'] = ['unum_total', '-', 'unum_used'];
             $state = Dever::db('user_source', 'place_order')->insert($data);
         } else {
-            $data['unum_total'] = array('+', $amount);
-            $data['unum_balance'] = array('unum_total', '-', 'unum_used');
+            $data['unum_total'] = ['+', $amount];
+            $data['unum_balance'] = ['unum_total', '-', 'unum_used'];
             $state = Dever::db('user_source', 'place_order')->update($info['id'], $data);
         }*/
     }

+ 25 - 25
src/place/order/lib/Source/Virtual.php

@@ -1,26 +1,26 @@
-<?php namespace Place_order\Lib\Source;
-use Dever;
-use Place;
-class Virtual
-{
-    public function up($id, $order_id, $content, $log = false)
-    {
-        $update['order_id'] = $order_id;
-        $update['content'] = $content;
-        if ($id) {
-            $info = Dever::db('source_virtual', 'place_order')->find($id);
-            if ($info) {
-                Dever::db('source_virtual', 'place_order')->update($info['id'], $update);
-            }
-        } else {
-            Dever::db('source_virtual', 'place_order')->insert($update);
-            Dever::db('source', 'place_order')->update($order_id, array('status' => 4, 'ddate' => time()));
-        }
-        if ($log) {
-            $type = $log['type'];
-            $uid = $log['uid'];
-            $msg = '已发货:' . $update['content'];
-            Dever::load('source/log', 'place_order')->up($type, $uid, $order_id, $msg);
-        }
-    }
+<?php namespace Place_order\Lib\Source;
+use Dever;
+use Place;
+class Virtual
+{
+    public function up($id, $order_id, $content, $log = false)
+    {
+        $update['order_id'] = $order_id;
+        $update['content'] = $content;
+        if ($id) {
+            $info = Dever::db('source_virtual', 'place_order')->find($id);
+            if ($info) {
+                Dever::db('source_virtual', 'place_order')->update($info['id'], $update);
+            }
+        } else {
+            Dever::db('source_virtual', 'place_order')->insert($update);
+            Dever::db('source', 'place_order')->update($order_id, ['status' => 4, 'ddate' => time()]);
+        }
+        if ($log) {
+            $type = $log['type'];
+            $uid = $log['uid'];
+            $msg = '已发货:' . $update['content'];
+            Dever::load('source/log', 'place_order')->up($type, $uid, $order_id, $msg);
+        }
+    }
 }

+ 44 - 44
src/place/order/manage/Lib/Source/Address.php

@@ -1,45 +1,45 @@
-<?php namespace Place_order\Manage\Lib\Source;
-use Dever;
-class Address
-{
-    public function update($db, $data)
-    {
-        $order = Dever::db('source', 'place_order')->find($data['id']);
-        if ($order) {
-            $uid = Dever::$data['muser']['id'];
-            $log['type'] = 2;
-            $log['uid'] = $uid;
-            $this->up($order['id'], $order['uid'], $order['address_id'], $data['address_name'], $data['address_phone'], $data['address_area'], $data['address_address'], $log);
-        }
-        return 'end';
-    }
-
-    public function up($order_id, $uid, $address_id, $name, $phone, $area, $address, $log = false)
-    {
-        $update['uid'] = $uid;
-        $update['name'] = $name;
-        $update['phone'] = $phone;
-        $update['type'] = 3;
-        $update['area'] = $area;
-        list($update['province_id'], $update['city_id'], $update['county_id']) = explode(',', $update['area']);
-        $update['address'] = $address;
-        $address = array();
-        if ($address_id) {
-            $address = Dever::db('address', 'place_user')->find($address_id);
-        }
-        if ($address && $address['type'] == 3) {
-            # 更新
-            Dever::db('address', 'place_user')->update($address['id'], $update);
-        } else {
-            $id = Dever::db('address', 'place_user')->insert($update);
-            Dever::db('source', 'place_order')->update($order_id, array('address_id' => $id));
-        }
-        $type = 1;
-        if ($log) {
-            $type = $log['type'];
-            $uid = $log['uid'];
-        }
-        $address = Dever::load('address', 'place_user')->handleInfo($update);
-        Dever::load('source/log', 'place_order')->up($type, $uid, $order_id, '更改收货地址:' . $address['full']);
-    }
+<?php namespace Place_order\Manage\Lib\Source;
+use Dever;
+class Address
+{
+    public function update($db, $data)
+    {
+        $order = Dever::db('source', 'place_order')->find($data['id']);
+        if ($order) {
+            $uid = Dever::$data['muser']['id'];
+            $log['type'] = 2;
+            $log['uid'] = $uid;
+            $this->up($order['id'], $order['uid'], $order['address_id'], $data['address_name'], $data['address_phone'], $data['address_area'], $data['address_address'], $log);
+        }
+        return 'end';
+    }
+
+    public function up($order_id, $uid, $address_id, $name, $phone, $area, $address, $log = false)
+    {
+        $update['uid'] = $uid;
+        $update['name'] = $name;
+        $update['phone'] = $phone;
+        $update['type'] = 3;
+        $update['area'] = $area;
+        list($update['province_id'], $update['city_id'], $update['county_id']) = explode(',', $update['area']);
+        $update['address'] = $address;
+        $address = [];
+        if ($address_id) {
+            $address = Dever::db('address', 'place_user')->find($address_id);
+        }
+        if ($address && $address['type'] == 3) {
+            # 更新
+            Dever::db('address', 'place_user')->update($address['id'], $update);
+        } else {
+            $id = Dever::db('address', 'place_user')->insert($update);
+            Dever::db('source', 'place_order')->update($order_id, ['address_id' => $id]);
+        }
+        $type = 1;
+        if ($log) {
+            $type = $log['type'];
+            $uid = $log['uid'];
+        }
+        $address = Dever::load('address', 'place_user')->handleInfo($update);
+        Dever::load('source/log', 'place_order')->up($type, $uid, $order_id, '更改收货地址:' . $address['full']);
+    }
 }

+ 322 - 364
src/place/order/manage/Lib/Source/Order.php

@@ -1,365 +1,323 @@
-<?php namespace Place_order\Manage\Lib\Source;
-use Dever;
-class Order
-{
-    # 后台详情页
-    public function getView($page)
-    {
-        # 这里获取基本信息
-        $db = Dever::db('sourcce', 'place_order');
-        $address = array();
-        if ($page->info['address_id']) {
-            $address = Dever::load('address', 'place_user')->getInfo($page->info['address_id'], $page->info['uid']);
-        }
-        $user = Dever::db('info', 'place_user')->find($page->info['uid']);
-        $desc = '';
-        $status = $db->value('status', $page->info);
-        if ($page->info['info']) {
-            $desc = '备注:' . $page->info['info'];
-        }
-        $timeline = array();
-        $page->info['cdate_str'] = date('Y-m-d H:i:s', $page->info['cdate']);
-        if (isset($page->info['pdate']) && $page->info['pdate']) {
-            $page->info['pdate_str'] = date('Y-m-d H:i:s', $page->info['pdate']);
-        }
-        if (isset($page->info['ddate']) && $page->info['ddate']) {
-            $page->info['ddate_str'] = date('Y-m-d H:i:s', $page->info['ddate']);
-        }
-        if (isset($page->info['qdate']) && $page->info['qdate']) {
-            $page->info['qdate_str'] = date('Y-m-d H:i:s', $page->info['qdate']);
-        }
-        if (isset($page->info['fdate']) && $page->info['fdate']) {
-            $page->info['fdate_str'] = date('Y-m-d H:i:s', $page->info['fdate']);
-        }
-        Dever::load('source/order', 'place_order')->getView($page->info);
-
-        foreach ($page->info['status_list'] as $k => $v) {
-            $v['name'] = '['.$v['name'].']';
-            if ($k == 1) {
-                $v['name'] .= ' 下单人:' . $user['name'] . '('.$user['mobile'].')' . ' 付款:' . $page->info['cash'] . '元 '. $desc;
-            } elseif ($k == 2) {
-                if ($address) {
-                    $v['name'] .= ' 收货地址:' . $address['full'];
-                }
-            } elseif ($k == 3) {
-                if (isset($page->info['express'])) {
-                    $v['name'] .= ' 已发货:' . $page->info['express']['name'] . ',' . $page->info['express']['number'];
-                }
-            } elseif ($k == 4) {
-                if (isset($page->info['express']['log'][0])) {
-                    $v['name'] .= ' ' . $page->info['express']['log'][0]['status'];
-                }
-            } elseif ($k == 5 && $page->info['status'] > 6) {
-                $v['name'] .= ' 订单'.$status.'';
-            }
-            if ($v['selected']) {
-                $v['hollow'] = true;
-                $v['color'] = '#0bbd87';
-                $v['type'] = 'primary';
-                $v['size'] = 'large';
-            }
-            $timeline[] = $v;
-        }
-        $button = array();
-
-        if ($page->info['status'] == 2) {
-            if ($page->info['source_type'] == 1) {
-                $button[] = array
-                (
-                    'name' => '修改收货信息',
-                    'type' => 'fastedit',
-                    'path' => 'sector_place_order/source_address',
-                    'row' => array
-                    (
-                        'id' => $page->info['id'],
-                    ),
-                );
-                $button[] = array
-                (
-                    'name' => '快递发货',
-                    # fastedit、fastadd、oper、api、link、route
-                    'type' => 'fastadd',
-                    'path' => 'sector_place_order/source_express',
-                    'row' => array
-                    (
-                        'id' => $page->info['id'],
-                    ),
-                    'param' => array
-                    (
-                        'order_id' => $page->info['id'],
-                    ),
-                );
-            } elseif ($page->info['source_type'] == 2) {
-                $button[] = array
-                (
-                    'name' => '虚拟发货',
-                    'type' => 'fastadd',
-                    'path' => 'sector_place_order/source_virtual',
-                    'row' => array
-                    (
-                        'id' => $page->info['id'],
-                    ),
-                    'param' => array
-                    (
-                        'order_id' => $page->info['id'],
-                    ),
-                );
-            }
-            
-        } elseif ($page->info['status'] == 3 && isset($express)) {
-            $button[] = array
-            (
-                'name' => '修改快递单号',
-                # fastedit、fastadd、oper、api、link、route
-                'type' => 'fastedit',
-                'path' => 'sector_place_order/source_express',
-                'row' => array
-                (
-                    'id' => $express['id'],
-                ),
-                'param' => array
-                (
-                    'order_id' => $page->info['id'],
-                ),
-            );
-        }
-        if (!$page->info['refund'] && $page->info['status'] >= 2 && $page->info['status'] < 7 && $page->info['source_type'] == 1) {
-            $button[] = array
-            (
-                'name' => '退款',
-                'type' => 'fastadd',
-                'path' => 'sector_place_order/source_refund',
-                'row' => array
-                (
-                    'id' => $page->info['id'],
-                ),
-                'param' => array
-                (
-                    'order_id' => $page->info['id'],
-                ),
-            );
-        }
-        $desc = '';
-        if ($page->info['refund']) {
-            $desc = '[退款中]';
-            $refund = array();
-            foreach ($page->info['refund_status_list'] as $k => $v) {
-                $v['name'] = '['.$v['name'].']';
-                if ($k == 1) {
-                    $v['name'] .= ' 申请原因:' . Dever::db('source_refund', 'place_order')->value('desc_type', $page->info['refund']['desc_type']) . ' 申请说明:' . $page->info['refund']['desc'];
-                } elseif ($k == 2) {
-                    $v['name'] .= ' 审核备注:' . $page->info['refund']['audit_desc'];
-                } elseif ($k == 3) {
-                    if (isset($page->info['refund']['express'])) {
-                        $v['name'] .= ' 已发货:' . $page->info['refund']['express']['name'] . ',' . $page->info['refund']['express']['number'];
-                    }
-                }
-                if ($v['selected']) {
-                    $v['hollow'] = true;
-                    $v['color'] = 'red';
-                    $v['type'] = 'primary';
-                    $v['size'] = 'large';
-                }
-                $refund[] = $v;
-            }
-            $content[] = array
-            (
-                'name' => '退款进度',
-                'type' => 'timeline',
-                'content' => $refund,
-            );
-            $button = array();
-            if ($page->info['refund']['status'] == 1) {
-                $button[] = array
-                (
-                    'name' => '退款审核',
-                    'type' => 'fastedit',
-                    'path' => 'sector_place_order/source_refund_audit',
-                    'row' => array
-                    (
-                        'id' => $page->info['refund']['id'],
-                    ),
-                    'param' => array
-                    (
-                        'order_id' => $page->info['id'],
-                    ),
-                );
-            }
-        }
-
-        $content[] = array
-        (
-            'name' => '订单进度' . $desc,
-            'type' => 'timeline',
-            'content' => $timeline,
-        );
-
-        $info[] = array
-        (
-            # 类型,desc描述 table表格,表格有head和body即可
-            'type' => 'desc',
-            'name' => $page->info['order_num'],
-            # 每行展示数量
-            'column' => 1,
-            # 是否有边框
-            'border' => true,
-            # 排列方向:horizontal横向 vertical纵向
-            'direction' => 'horizontal',
-            # 右侧按钮
-            'button' => $button,
-            # 具体内容
-            'content' => $content,
-        );
-
-        $detail = Dever::db('source_detail', 'place_order')->select(array('order_id' => $page->info['id']));
-        if ($detail) {
-            foreach ($detail as &$v) {
-                $v['status'] = '正常';
-            }
-        }
-
-        $log = Dever::load('source/log', 'place_order')->getList($page->info['id']);
-
-        # 退款信息
-        $refund = array();
-        //$refund = Dever::load('source/refund', 'place_order')->getList($page->info['id']);
-        
-        $tab = array
-        (
-            'active' => 't1',
-        );
-
-        $tab['content']['t1'] = array
-        (
-            'name' => '商品清单',
-            'type' => 'table',
-            'border' => true,
-            #'height' => '200',
-            'head' => array
-            (
-                array
-                (
-                    'key' => 'name',
-                    'name' => '名称',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'sku_name',
-                    'name' => '规格',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'cash',
-                    'name' => '金额',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'num',
-                    'name' => '数量',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'status',
-                    'name' => '状态',
-                    'fixed' => 'fixed',
-                ),
-            ),
-            'button' => array(),
-            'body' => $detail,
-        );
-
-        if ($refund) {
-            $tab['content']['t2'] = array
-            (
-                'name' => '退款记录',
-                'type' => 'table',
-                'border' => true,
-                #'height' => '200',
-                'head' => array
-                (
-                    array
-                    (
-                        'key' => 'name',
-                        'name' => '名称',
-                        'fixed' => 'fixed',
-                    ),
-                    array
-                    (
-                        'key' => 'sku_name',
-                        'name' => '规格',
-                        'fixed' => 'fixed',
-                    ),
-                    array
-                    (
-                        'key' => 'cash',
-                        'name' => '金额',
-                        'fixed' => 'fixed',
-                    ),
-                    array
-                    (
-                        'key' => 'status',
-                        'name' => '状态',
-                        'fixed' => 'fixed',
-                    ),
-                    array
-                    (
-                        'key' => 'cdate_str',
-                        'name' => '时间',
-                        'fixed' => 'fixed',
-                    ),
-                ),
-                'button' => array(),
-                'body' => $refund,
-            );
-        }
-
-        $tab['content']['t3'] = array
-        (
-            'name' => '操作记录',
-            'type' => 'table',
-            'border' => true,
-            #'height' => '200',
-            'head' => array
-            (
-                array
-                (
-                    'key' => 'type',
-                    'name' => '身份',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'name',
-                    'name' => '名称',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'mobile',
-                    'name' => '联系电话',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'desc',
-                    'name' => '详情',
-                    'fixed' => 'fixed',
-                ),
-                array
-                (
-                    'key' => 'cdate_str',
-                    'name' => '时间',
-                    'fixed' => 'fixed',
-                ),
-            ),
-            'button' => array(),
-            'body' => $log,
-        );
-        
-        return array('info' => $info, 'tab' => $tab);
-    }
+<?php namespace Place_order\Manage\Lib\Source;
+use Dever;
+class Order
+{
+    # 后台详情页
+    public function getView($page)
+    {
+        # 这里获取基本信息
+        $db = Dever::db('source', 'place_order');
+        $address = [];
+        if ($page->info['address_id']) {
+            $address = Dever::load('address', 'place_user')->getInfo($page->info['address_id'], $page->info['uid']);
+        }
+        $user = Dever::db('info', 'place_user')->find($page->info['uid']);
+        $desc = '';
+        $status = $db->value('status', $page->info);
+        if ($page->info['info']) {
+            $desc = '备注:' . $page->info['info'];
+        }
+        $timeline = [];
+        $page->info['cdate_str'] = date('Y-m-d H:i:s', $page->info['cdate']);
+        if (isset($page->info['pdate']) && $page->info['pdate']) {
+            $page->info['pdate_str'] = date('Y-m-d H:i:s', $page->info['pdate']);
+        }
+        if (isset($page->info['ddate']) && $page->info['ddate']) {
+            $page->info['ddate_str'] = date('Y-m-d H:i:s', $page->info['ddate']);
+        }
+        if (isset($page->info['qdate']) && $page->info['qdate']) {
+            $page->info['qdate_str'] = date('Y-m-d H:i:s', $page->info['qdate']);
+        }
+        if (isset($page->info['fdate']) && $page->info['fdate']) {
+            $page->info['fdate_str'] = date('Y-m-d H:i:s', $page->info['fdate']);
+        }
+        $page->info = Dever::load('source/order', 'place_order')->getView($page->info);
+
+        foreach ($page->info['status_list'] as $k => $v) {
+            $v['name'] = '['.$v['name'].']';
+            if ($k == 1) {
+                $v['name'] .= ' 下单人:' . $user['name'] . '('.$user['mobile'].')' . ' 付款:' . $page->info['cash'] . '元 '. $desc;
+            } elseif ($k == 2) {
+                if ($address) {
+                    $v['name'] .= ' 收货地址:' . $address['full'];
+                }
+            } elseif ($k == 3) {
+                if (isset($page->info['express'])) {
+                    $v['name'] .= ' 已发货:' . $page->info['express']['name'] . ',' . $page->info['express']['number'];
+                }
+            } elseif ($k == 4) {
+                if (isset($page->info['express']['log'][0])) {
+                    $v['name'] .= ' ' . $page->info['express']['log'][0]['status'];
+                }
+            } elseif ($k == 5 && $page->info['status'] > 6) {
+                $v['name'] .= ' 订单'.$status.'';
+            }
+            if ($v['selected']) {
+                $v['hollow'] = true;
+                $v['color'] = '#0bbd87';
+                $v['type'] = 'primary';
+                $v['size'] = 'large';
+            }
+            $timeline[] = $v;
+        }
+        $button = [];
+
+        if ($page->info['status'] == 2) {
+            if ($page->info['source_type'] == 1) {
+                $button[] = [
+                    'name' => '修改收货信息',
+                    'type' => 'fastedit',
+                    'path' => 'sector_place_order/source_address',
+                    'row' => [
+                        'id' => $page->info['id'],
+                    ],
+                ];
+                $button[] = [
+                    'name' => '快递发货',
+                    # fastedit、fastadd、oper、api、link、route
+                    'type' => 'fastadd',
+                    'path' => 'sector_place_order/source_express',
+                    'row' => [
+                        'id' => $page->info['id'],
+                    ],
+                    'param' => [
+                        'order_id' => $page->info['id'],
+                    ],
+                ];
+            } elseif ($page->info['source_type'] == 2) {
+                $button[] = [
+                    'name' => '虚拟发货',
+                    'type' => 'fastadd',
+                    'path' => 'sector_place_order/source_virtual',
+                    'row' => [
+                        'id' => $page->info['id'],
+                    ],
+                    'param' => [
+                        'order_id' => $page->info['id'],
+                    ],
+                ];
+            }
+            
+        } elseif ($page->info['status'] == 3 && isset($express)) {
+            $button[] = [
+                'name' => '修改快递单号',
+                # fastedit、fastadd、oper、api、link、route
+                'type' => 'fastedit',
+                'path' => 'sector_place_order/source_express',
+                'row' => [
+                    'id' => $express['id'],
+                ],
+                'param' => [
+                    'order_id' => $page->info['id'],
+                ],
+            ];
+        }
+        if (!$page->info['refund'] && $page->info['status'] >= 2 && $page->info['status'] < 7 && $page->info['source_type'] == 1) {
+            $button[] = [
+                'name' => '退款',
+                'type' => 'fastadd',
+                'path' => 'sector_place_order/source_refund',
+                'row' => [
+                    'id' => $page->info['id'],
+                ],
+                'param' => [
+                    'order_id' => $page->info['id'],
+                ],
+            ];
+        }
+        $desc = '';
+        if ($page->info['refund']) {
+            $desc = '[退款中]';
+            $refund = [];
+            foreach ($page->info['refund_status_list'] as $k => $v) {
+                $v['name'] = '['.$v['name'].']';
+                if ($k == 1) {
+                    $v['name'] .= ' 申请原因:' . Dever::db('source_refund', 'place_order')->value('desc_type', $page->info['refund']['desc_type']) . ' 申请说明:' . $page->info['refund']['desc'];
+                } elseif ($k == 2) {
+                    $v['name'] .= ' 审核备注:' . $page->info['refund']['audit_desc'];
+                } elseif ($k == 3) {
+                    if (isset($page->info['refund']['express'])) {
+                        $v['name'] .= ' 已发货:' . $page->info['refund']['express']['name'] . ',' . $page->info['refund']['express']['number'];
+                    }
+                }
+                if ($v['selected']) {
+                    $v['hollow'] = true;
+                    $v['color'] = 'red';
+                    $v['type'] = 'primary';
+                    $v['size'] = 'large';
+                }
+                $refund[] = $v;
+            }
+            $content[] = [
+                'name' => '退款进度',
+                'type' => 'timeline',
+                'content' => $refund,
+            ];
+            $button = [];
+            if ($page->info['refund']['status'] == 1) {
+                $button[] = [
+                    'name' => '退款审核',
+                    'type' => 'fastedit',
+                    'path' => 'sector_place_order/source_refund_audit',
+                    'row' => [
+                        'id' => $page->info['refund']['id'],
+                    ],
+                    'param' => [
+                        'order_id' => $page->info['id'],
+                    ],
+                ];
+            }
+        }
+
+        $content[] = [
+            'name' => '订单进度' . $desc,
+            'type' => 'timeline',
+            'content' => $timeline,
+        ];
+
+        $info[] = [
+            # 类型,desc描述 table表格,表格有head和body即可
+            'type' => 'desc',
+            'name' => $page->info['order_num'],
+            # 每行展示数量
+            'column' => 1,
+            # 是否有边框
+            'border' => true,
+            # 排列方向:horizontal横向 vertical纵向
+            'direction' => 'horizontal',
+            # 右侧按钮
+            'button' => $button,
+            # 具体内容
+            'content' => $content,
+        ];
+
+        $detail = Dever::db('source_detail', 'place_order')->select(['order_id' => $page->info['id']]);
+        if ($detail) {
+            foreach ($detail as &$v) {
+                $v['status'] = '正常';
+            }
+        }
+
+        $log = Dever::load('source/log', 'place_order')->getList($page->info['id']);
+
+        # 退款信息
+        $refund = [];
+        //$refund = Dever::load('source/refund', 'place_order')->getList($page->info['id']);
+        
+        $tab = [
+            'active' => 't1',
+        ];
+
+        $tab['content']['t1'] = [
+            'name' => '商品清单',
+            'type' => 'table',
+            'border' => true,
+            #'height' => '200',
+            'head' => [
+                [
+                    'key' => 'name',
+                    'name' => '名称',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'sku_name',
+                    'name' => '规格',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'cash',
+                    'name' => '金额',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'num',
+                    'name' => '数量',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'status',
+                    'name' => '状态',
+                    'fixed' => 'fixed',
+                ],
+            ],
+            'button' => [],
+            'body' => $detail,
+        ];
+
+        if ($refund) {
+            $tab['content']['t2'] = [
+                'name' => '退款记录',
+                'type' => 'table',
+                'border' => true,
+                #'height' => '200',
+                'head' => [
+                    [
+                        'key' => 'name',
+                        'name' => '名称',
+                        'fixed' => 'fixed',
+                    ],
+                    [
+                        'key' => 'sku_name',
+                        'name' => '规格',
+                        'fixed' => 'fixed',
+                    ],
+                    [
+                        'key' => 'cash',
+                        'name' => '金额',
+                        'fixed' => 'fixed',
+                    ],
+                    [
+                        'key' => 'status',
+                        'name' => '状态',
+                        'fixed' => 'fixed',
+                    ],
+                    [
+                        'key' => 'cdate_str',
+                        'name' => '时间',
+                        'fixed' => 'fixed',
+                    ],
+                ],
+                'button' => [],
+                'body' => $refund,
+            ];
+        }
+
+        $tab['content']['t3'] = [
+            'name' => '操作记录',
+            'type' => 'table',
+            'border' => true,
+            #'height' => '200',
+            'head' => [
+                [
+                    'key' => 'type',
+                    'name' => '身份',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'name',
+                    'name' => '名称',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'mobile',
+                    'name' => '联系电话',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'desc',
+                    'name' => '详情',
+                    'fixed' => 'fixed',
+                ],
+                [
+                    'key' => 'cdate_str',
+                    'name' => '时间',
+                    'fixed' => 'fixed',
+                ],
+            ],
+            'button' => [],
+            'body' => $log,
+        ];
+        
+        return ['info' => $info, 'tab' => $tab];
+    }
 }

+ 58 - 67
src/place/order/manage/core.php

@@ -1,67 +1,58 @@
-<?php
-return array
-(
-    'menu' => array
-    (
-        'source' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '商品订单',
-            'icon'      => 'product-hunt-line',
-            'sort'      => '1',
-        ),
-
-        'source_address' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '订单地址',
-            'icon'      => 'product-hunt-line',
-            'sort'      => '10',
-            'show'      => 3,
-        ),
-
-        'source_express' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '快递发货',
-            'icon'      => 'product-hunt-line',
-            'sort'      => '10',
-            'show'      => 3,
-        ),
-
-        'source_virtual' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '虚拟发货',
-            'icon'      => 'product-hunt-line',
-            'sort'      => '10',
-            'show'      => 3,
-        ),
-
-        'source_refund' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '订单退款',
-            'icon'      => 'product-hunt-line',
-            'sort'      => '10',
-            'show'      => 3,
-        ),
-
-        'source_refund_audit' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '订单退款审核',
-            'icon'      => 'product-hunt-line',
-            'sort'      => '10',
-            'show'      => 3,
-        ),
-
-        'role' => array
-        (
-            'parent'    => 'sector_place_order',
-            'name'      => '角色订单',
-            'icon'      => 'shield-user-line',
-            'sort'      => '2',
-        ),
-    ),
-);
+<?php
+return [
+    'menu' => [
+        'source' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '商品订单',
+            'icon'      => 'product-hunt-line',
+            'sort'      => '1',
+        ],
+
+        'source_address' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '订单地址',
+            'icon'      => 'product-hunt-line',
+            'sort'      => '10',
+            'show'      => 3,
+        ],
+
+        'source_express' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '快递发货',
+            'icon'      => 'product-hunt-line',
+            'sort'      => '10',
+            'show'      => 3,
+        ],
+
+        'source_virtual' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '虚拟发货',
+            'icon'      => 'product-hunt-line',
+            'sort'      => '10',
+            'show'      => 3,
+        ],
+
+        'source_refund' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '订单退款',
+            'icon'      => 'product-hunt-line',
+            'sort'      => '10',
+            'show'      => 3,
+        ],
+
+        'source_refund_audit' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '订单退款审核',
+            'icon'      => 'product-hunt-line',
+            'sort'      => '10',
+            'show'      => 3,
+        ],
+
+        'role' => [
+            'parent'    => 'sector_place_order',
+            'name'      => '角色订单',
+            'icon'      => 'shield-user-line',
+            'sort'      => '2',
+        ],
+    ],
+];

+ 37 - 45
src/place/order/manage/role.php

@@ -1,46 +1,38 @@
-<?php
-$config = array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'order_num',
-            'name',
-            'uid' => array
-            (
-                'name' => '用户信息',
-                'show' => 'Dever::call("place_user/manage/user.getInfo", {uid})',
-            ),
-            'cash',
-            'status',
-            'cdate',
-        ),
-        'button' => array
-        (
-            
-        ),
-        'data_button' => array
-        (
-            
-        ),
-        'search'    => array
-        (
-            'order_num',
-            'uid',
-            'name' => 'like',
-            'cdate' => array
-            (
-                'name' => '创建时间',
-                'type' => 'date',
-                'date_type' => 'datetimerange',
-                'value_format' => 'YYYY-MM-DD HH:mm:ss',
-                'start_placeholder' => '开始日期',
-                'end_placeholder' => '结束日期',
-                'range_separator' => '至',
-            ),
-            'status',
-        ),
-    ),
-);
+<?php
+$config = [
+    'list' => [
+        'field'      => [
+            'order_num',
+            'name',
+            'uid' => [
+                'name' => '用户信息',
+                'show' => 'Dever::call("place_user/manage/user.getInfo", {uid})',
+            ],
+            'cash',
+            'status',
+            'cdate',
+        ],
+        'button' => [
+            
+        ],
+        'data_button' => [
+            
+        ],
+        'search'    => [
+            'order_num',
+            'uid',
+            'name' => 'like',
+            'cdate' => [
+                'name' => '创建时间',
+                'type' => 'date',
+                'date_type' => 'datetimerange',
+                'value_format' => 'YYYY-MM-DD HH:mm:ss',
+                'start_placeholder' => '开始日期',
+                'end_placeholder' => '结束日期',
+                'range_separator' => '至',
+            ],
+            'status',
+        ],
+    ],
+];
 return $config;

+ 50 - 60
src/place/order/manage/source.php

@@ -1,61 +1,51 @@
-<?php
-$config = array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'order_num',
-            'name',
-            'uid' => array
-            (
-                'name' => '用户信息',
-                'show' => 'Dever::call("place_user/manage/user.getInfo", {uid})',
-            ),
-            'cash',
-            'num',
-            'status',
-            'refund_status',
-            'cdate',
-        ),
-        'button' => array
-        (
-            //'新增' => array('add'),
-        ),
-        'data_button' => array
-        (
-            //'编辑' => 'edit',
-            '详情' => array('view', array
-            (
-                'path' => 'sector_place_order/source',
-                'param' => array
-                (
-                    'type' => 'view',
-                    'id' => 'id',
-                    'set' => array('menu' => 'sector_place_order/source', 'parent' => 'sector_place_order/source'),
-                ),
-            )),
-        ),
-        'search'    => array
-        (
-            'order_num',
-            'uid',
-            'name' => 'like',
-            'cdate' => array
-            (
-                'name' => '创建时间',
-                'type' => 'date',
-                'date_type' => 'datetimerange',
-                'value_format' => 'YYYY-MM-DD HH:mm:ss',
-                'start_placeholder' => '开始日期',
-                'end_placeholder' => '结束日期',
-                'range_separator' => '至',
-            ),
-            'status',
-            'refund_status',
-        ),
-    ),
-    # 详情页配置
-    'view' => 'place_order/manage/source/order.getView',
-);
+<?php
+$config = [
+    'list' => [
+        'field'      => [
+            'order_num',
+            'name',
+            'uid' => [
+                'name' => '用户信息',
+                'show' => 'Dever::call("place_user/manage/user.getInfo", {uid})',
+            ],
+            'cash',
+            'num',
+            'status',
+            'refund_status',
+            'cdate',
+        ],
+        'button' => [
+            //'新增' => ['add'],
+        ],
+        'data_button' => [
+            //'编辑' => 'edit',
+            '详情' => ['view', [
+                'path' => 'sector_place_order/source',
+                'param' => [
+                    'type' => 'view',
+                    'id' => 'id',
+                    'set' => ['menu' => 'sector_place_order/source', 'parent' => 'sector_place_order/source'],
+                ],
+            ]],
+        ],
+        'search'    => [
+            'order_num',
+            'uid',
+            'name' => 'like',
+            'cdate' => [
+                'name' => '创建时间',
+                'type' => 'date',
+                'date_type' => 'datetimerange',
+                'value_format' => 'YYYY-MM-DD HH:mm:ss',
+                'start_placeholder' => '开始日期',
+                'end_placeholder' => '结束日期',
+                'range_separator' => '至',
+            ],
+            'status',
+            'refund_status',
+        ],
+    ],
+    # 详情页配置
+    'view' => 'place_order/manage/source/order.getView',
+];
 return $config;

+ 40 - 48
src/place/order/manage/source_address.php

@@ -1,49 +1,41 @@
-<?php
-$id = Dever::input('id');
-$info = Dever::db('source', 'place_order')->find($id);
-if ($info['address_id']) {
-    $address = Dever::db('address', 'place_user')->find($info['address_id']);
-}
-
-$config = array
-(
-    'source' => 'place_order/source',
-    'update' => array
-    (
-        'start' => 'place_order/manage/source/address.update',
-        'field'    => array
-        (
-            'address_id' => array
-            (
-                'value' => $address['id'] ?? '',
-                'type' => 'hidden',
-            ),
-            'address_name' => array
-            (
-                'name' => '联系人',
-                'value' => $address['name'] ?? '',
-            ),
-            'address_phone' => array
-            (
-                'name' => '联系电话',
-                'value' => $address['phone'] ?? '',
-            ),
-            'address_area' => array
-            (
-                'name' => '城市地区',
-                'type' => 'cascader',
-                'remote'    => Dever::url('area/data.get&total=3'),
-                'value'     => $address['area'] ?? '',
-            ),
-            'address_address' => array
-            (
-                'name' => '详细地址',
-                'type' => 'textarea',
-                'autosize' => array('minRows' => 2),
-                'value' => $address['address'] ?? '',
-            ),
-        ),
-    ),
-);
-
+<?php
+$id = Dever::input('id');
+$info = Dever::db('source', 'place_order')->find($id);
+if ($info['address_id']) {
+    $address = Dever::db('address', 'place_user')->find($info['address_id']);
+}
+
+$config = [
+    'source' => 'place_order/source',
+    'update' => [
+        'start' => 'place_order/manage/source/address.update',
+        'field'    => [
+            'address_id' => [
+                'value' => $address['id'] ?? '',
+                'type' => 'hidden',
+            ],
+            'address_name' => [
+                'name' => '联系人',
+                'value' => $address['name'] ?? '',
+            ],
+            'address_phone' => [
+                'name' => '联系电话',
+                'value' => $address['phone'] ?? '',
+            ],
+            'address_area' => [
+                'name' => '城市地区',
+                'type' => 'cascader',
+                'remote'    => Dever::url('area/data.get&total=3'),
+                'value'     => $address['area'] ?? '',
+            ],
+            'address_address' => [
+                'name' => '详细地址',
+                'type' => 'textarea',
+                'autosize' => ['minRows' => 2],
+                'value' => $address['address'] ?? '',
+            ],
+        ],
+    ],
+];
+
 return $config;

+ 23 - 29
src/place/order/manage/source_express.php

@@ -1,30 +1,24 @@
-<?php
-$id = Dever::input('field')['order_id'];
-$config = array
-(
-    'update' => array
-    (
-        'start' => 'place_order/manage/source/express.update',
-        'field'    => array
-        (
-            'order_id' => array
-            (
-                'value' => $id,
-                'type' => 'hidden',
-            ),
-            'express_id' => array
-            (
-                'rules' => true,
-                'type' => 'select',
-            ),
-            'number' => array
-            (
-                'rules' => true,
-                'type' => 'textarea',
-                'autosize' => array('minRows' => 2),
-            ),
-        ),
-    ),
-);
-
+<?php
+$id = Dever::input('field')['order_id'];
+$config = [
+    'update' => [
+        'start' => 'place_order/manage/source/express.update',
+        'field'    => [
+            'order_id' => [
+                'value' => $id,
+                'type' => 'hidden',
+            ],
+            'express_id' => [
+                'rules' => true,
+                'type' => 'select',
+            ],
+            'number' => [
+                'rules' => true,
+                'type' => 'textarea',
+                'autosize' => ['minRows' => 2],
+            ],
+        ],
+    ],
+];
+
 return $config;

+ 33 - 42
src/place/order/manage/source_refund.php

@@ -1,43 +1,34 @@
-<?php
-$id = Dever::input('field')['order_id'];
-$config = array
-(
-    'update' => array
-    (
-        'start' => 'place_order/manage/source/refund.update',
-        'field'    => array
-        (
-            'order_id' => array
-            (
-                'value' => $id,
-                'type' => 'hidden',
-            ),
-            'type' => array
-            (
-                'rules' => true,
-                'type' => 'radio',
-            ),
-            'cash' => array
-            (
-                'rules' => true,
-            ),
-            'place_order/source_refund_detail' => array
-            (
-                'name' => '退款明细',
-                'where'  => array('order_refund_id' => 'id'),
-            ),
-            'desc_type' => array
-            (
-                'rules' => true,
-            ),
-            'desc' => array
-            (
-                'rules' => true,
-                'type' => 'textarea',
-                'autosize' => array('minRows' => 2),
-            ),
-        ),
-    ),
-);
-
+<?php
+$id = Dever::input('field')['order_id'];
+$config = [
+    'update' => [
+        'start' => 'place_order/manage/source/refund.update',
+        'field'    => [
+            'order_id' => [
+                'value' => $id,
+                'type' => 'hidden',
+            ],
+            'type' => [
+                'rules' => true,
+                'type' => 'radio',
+            ],
+            'cash' => [
+                'rules' => true,
+            ],
+            'place_order/source_refund_detail' => [
+                'name' => '退款明细',
+                'where'  => ['order_refund_id' => 'id'],
+            ],
+            'desc_type' => [
+                'rules' => true,
+            ],
+            'desc' => [
+                'rules' => true,
+                'type' => 'textarea',
+                'autosize' => ['minRows' => 2],
+            ],
+        ],
+    ],
+];
+
 return $config;

+ 26 - 32
src/place/order/manage/source_refund_audit.php

@@ -1,33 +1,27 @@
-<?php
-$config = array
-(
-    'source' => 'place_order/source_refund',
-    'update' => array
-    (
-        'start' => 'place_order/manage/source/refund.audit',
-        'field'    => array
-        (
-            'audit' => array
-            (
-                'name' => '退款审核',
-                'rules' => true,
-                'type' => 'radio',
-                'option' => array
-                (
-                    1 => '审核通过',
-                    2 => '审核驳回',
-                ),
-                'default' => 1,
-            ),
-            'audit_desc' => array
-            (
-                'name' => '审核备注',
-                //'rules' => true,
-                'type' => 'textarea',
-                'autosize' => array('minRows' => 2),
-            ),
-        ),
-    ),
-);
-
+<?php
+$config = [
+    'source' => 'place_order/source_refund',
+    'update' => [
+        'start' => 'place_order/manage/source/refund.audit',
+        'field'    => [
+            'audit' => [
+                'name' => '退款审核',
+                'rules' => true,
+                'type' => 'radio',
+                'option' => [
+                    1 => '审核通过',
+                    2 => '审核驳回',
+                ],
+                'default' => 1,
+            ],
+            'audit_desc' => [
+                'name' => '审核备注',
+                //'rules' => true,
+                'type' => 'textarea',
+                'autosize' => ['minRows' => 2],
+            ],
+        ],
+    ],
+];
+
 return $config;

+ 17 - 22
src/place/order/manage/source_refund_detail.php

@@ -1,22 +1,17 @@
-<?php
-$id = Dever::input('field')['order_id'];
-$detail = Dever::db('source_detail', 'place_order')->select(array('order_id' => $id, 'status' => 1), array('col' => 'concat(name,"-",sku_name) as name, id'));
-return array
-(
-    'update' => array
-    (
-        'field'    => array
-        (
-            'detail_id' => array
-            (
-                'type' => 'select',
-                'clearable' => true,
-                'option' => $detail,
-            ),
-            'num' => array
-            (
-                
-            ),
-        ),
-    ),
-);
+<?php
+$id = Dever::input('field')['order_id'];
+$detail = Dever::db('source_detail', 'place_order')->select(['order_id' => $id, 'status' => 1], ['col' => 'concat(name,"-",sku_name) as name, id']);
+return [
+    'update' => [
+        'field'    => [
+            'detail_id' => [
+                'type' => 'select',
+                'clearable' => true,
+                'option' => $detail,
+            ],
+            'num' => [
+                
+            ],
+        ],
+    ],
+];

+ 20 - 25
src/place/order/manage/source_virtual.php

@@ -1,26 +1,21 @@
-<?php
-$id = Dever::input('field')['order_id'];
-$config = array
-(
-    'update' => array
-    (
-        'start' => 'place_order/manage/source/virtual.update',
-        'field'    => array
-        (
-            'order_id' => array
-            (
-                'value' => $id,
-                'type' => 'hidden',
-            ),
-            'content' => array
-            (
-                'rules' => true,
-                'type' => 'textarea',
-                'autosize' => array('minRows' => 6),
-                'tips' => '',
-            ),
-        ),
-    ),
-);
-
+<?php
+$id = Dever::input('field')['order_id'];
+$config = [
+    'update' => [
+        'start' => 'place_order/manage/source/virtual.update',
+        'field'    => [
+            'order_id' => [
+                'value' => $id,
+                'type' => 'hidden',
+            ],
+            'content' => [
+                'rules' => true,
+                'type' => 'textarea',
+                'autosize' => ['minRows' => 6],
+                'tips' => '',
+            ],
+        ],
+    ],
+];
+
 return $config;

+ 87 - 92
src/place/order/table/role.php

@@ -1,92 +1,87 @@
-<?php
-return array
-(
-    'name' => '角色等级支付订单表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'type' => array
-        (
-            'name'      => '角色',
-            'type'      => 'tinyint(1)',
-        ),
-
-        'type_id' => array
-        (
-            'name'      => '角色id',
-            'type'      => 'int(11)',
-        ),
-
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-
-        'name'      => array
-        (
-            'type'      => 'varchar(255)',
-            'name'      => '订单名称',
-        ),
-
-        'order_num'        => array
-        (
-            'type'      => 'varchar(60)',
-            'name'      => '订单号',
-        ),
-
-        'cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '订单金额',
-        ),
-
-        'pay_cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '支付金额',
-        ),
-
-        'wallet_cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '钱包金额',
-        ),
-
-        'user_coupon_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户优惠券id',
-        ),
-
-        'coupon_cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '优惠券金额',
-        ),
-
-        'status'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '订单状态',
-            'default'   => '1',
-            'value'         => array
-            (
-                1 => '待支付',
-                2 => '已完成',
-                3 => '已取消',
-            ),
-        ),
-
-        'pdate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '付款时间',
-        ),
-    ),
-
-    'index' => array
-    (
-        'search' => 'uid',
-    ),
-);
+<?php
+return [
+    'name' => '角色等级支付订单表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'name'      => [
+            'type'      => 'varchar(255)',
+            'name'      => '订单名称',
+        ],
+
+        'order_num'        => [
+            'type'      => 'varchar(60)',
+            'name'      => '订单号',
+        ],
+
+        'score_id' => [
+            'name'      => '积分',
+            'type'      => 'int(11)',
+        ],
+
+        'score_exp' => [
+            'name'      => '货币换算',
+            'type'      => 'varchar(50)',
+            'default'   => '0',
+        ],
+
+        'cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '订单金额',
+        ],
+
+        'num'      => [
+            'type'      => 'int(11)',
+            'name'      => '数量',
+        ],
+
+        'pay_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '支付金额',
+        ],
+
+        'pay_money_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '支付货币',
+        ],
+
+        'wallet_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '钱包金额',
+        ],
+
+        'user_coupon_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户优惠券id',
+        ],
+
+        'coupon_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '优惠券金额',
+        ],
+
+        'status'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'value'         => [
+                1 => '待支付',
+                2 => '已完成',
+                3 => '已取消',
+            ],
+        ],
+
+        'pdate'       => [
+            'type'      => 'int(11)',
+            'name'      => '付款时间',
+        ],
+    ],
+
+    'index' => [
+        'search' => 'uid,order_num',
+    ],
+];

+ 61 - 0
src/place/order/table/role_detail.php

@@ -0,0 +1,61 @@
+<?php
+return [
+    'name' => '角色等级支付订单明细表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'role_id' => [
+            'name'      => '角色',
+            'type'      => 'int(11)',
+        ],
+
+        'level_id' => [
+            'name'      => '等级',
+            'type'      => 'int(11)',
+        ],
+
+        'level' => [
+            'name'      => '等级数字',
+            'type'      => 'int(11)',
+        ],
+
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'name'      => [
+            'type'      => 'varchar(255)',
+            'name'      => '名称',
+        ],
+
+        'cash'      => [
+            'type'      => 'decimal(11,2)',
+            'name'      => '明细金额',
+        ],
+
+        'num'      => [
+            'type'      => 'int(11)',
+            'name'      => '明细数量',
+        ],
+
+        'status'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '明细状态',
+            'default'   => '1',
+            'value'         => [
+                1 => '正常',
+                2 => '部分退款',
+                3 => '已全部退款',
+            ],
+        ],
+    ],
+
+    'index' => [
+        'search' => 'order_id,role_id,level_id',
+    ],
+];

+ 33 - 0
src/place/order/table/role_log.php

@@ -0,0 +1,33 @@
+<?php
+return [
+    'name' => '角色订单日志表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'type' => [
+            'name'      => '操作人类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                -1 => '系统',
+                1 => '买家',
+                2 => '卖家',
+                3 => '渠道',
+            ],
+        ],
+
+        'type_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '操作人',
+        ],
+
+        'desc'      => [
+            'type'      => 'varchar(1000)',
+            'name'      => '操作明细',
+        ],
+    ],
+];

+ 145 - 153
src/place/order/table/source.php

@@ -1,153 +1,145 @@
-<?php
-return array
-(
-    'name' => '资源支付订单表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'source_type' => array
-        (
-            'name'      => '资源类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-        ),
-
-        'address_id' => array
-        (
-            'name'      => '地址ID',
-            'type'      => 'int(11)',
-        ),
-
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户ID',
-        ),
-
-        'order_num'        => array
-        (
-            'type'      => 'varchar(60)',
-            'name'      => '订单号',
-        ),
-
-        'name'      => array
-        (
-            'type'      => 'varchar(255)',
-            'name'      => '订单名称',
-        ),
-
-        'cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '金额',
-        ),
-
-        'pay_cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '支付金额',
-        ),
-
-        'wallet_cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '钱包金额',
-        ),
-
-        'user_coupon_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户优惠券id',
-        ),
-
-        'coupon_cash'      => array
-        (
-            'type'      => 'decimal(20,2)',
-            'name'      => '优惠券金额',
-        ),
-
-        'num'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '数量',
-        ),
-
-        'info'      => array
-        (
-            'type'      => 'varchar(80)',
-            'name'      => '订单备注',
-        ),
-
-        'type'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '订单类型',
-            'default'   => '1',
-            'value'         => array
-            (
-                1 => '源代宝订单',
-                2 => '第三方订单',
-            ),
-        ),
-
-        'refund_status'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '退款申请状态',
-            'default'   => '2',
-            'value'         => array
-            (
-                1 => '退款申请中',
-                2 => '无退款申请',
-            ),
-        ),
-
-        'status'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '订单状态',
-            'default'   => '1',
-            'value'         => array
-            (
-                1 => '待支付',
-                2 => '待发货',
-                3 => '已发货',
-                4 => '待收货',
-                5 => '已完成',
-                6 => '已完成(有退款)',
-                7 => '已取消',
-                8 => '已退款',
-                9 => '已过期',
-            ),
-        ),
-
-        'pdate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '付款时间',
-        ),
-
-        'ddate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '发货时间',
-        ),
-
-        'qdate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '签收时间',
-        ),
-
-        'fdate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '完成时间',
-        ),
-    ),
-
-    'index' => array
-    (
-        'search' => 'uid',
-    ),
-);
+<?php
+return [
+    'name' => '资源支付订单表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'source_type' => [
+            'name'      => '资源类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+        ],
+
+        'address_id' => [
+            'name'      => '地址ID',
+            'type'      => 'int(11)',
+        ],
+
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户ID',
+        ],
+
+        'order_num'        => [
+            'type'      => 'varchar(60)',
+            'name'      => '订单号',
+        ],
+
+        'name'      => [
+            'type'      => 'varchar(255)',
+            'name'      => '订单名称',
+        ],
+
+        'score_id' => [
+            'name'      => '积分',
+            'type'      => 'int(11)',
+        ],
+
+        'score_exp' => [
+            'name'      => '货币换算',
+            'type'      => 'varchar(50)',
+            'default'   => '0',
+        ],
+
+        'cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '金额',
+        ],
+
+        'pay_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '支付金额',
+        ],
+
+        'pay_money_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '支付货币',
+        ],
+
+        'wallet_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '钱包金额',
+        ],
+
+        'user_coupon_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户优惠券id',
+        ],
+
+        'coupon_cash'      => [
+            'type'      => 'decimal(20,2)',
+            'name'      => '优惠券金额',
+        ],
+
+        'num'      => [
+            'type'      => 'int(11)',
+            'name'      => '数量',
+        ],
+
+        'info'      => [
+            'type'      => 'varchar(80)',
+            'name'      => '订单备注',
+        ],
+
+        'deliver_type' => [
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '快递发货',//需手动或者自动发货
+                2 => '虚拟发货',//需手动或者自动发货
+                3 => '无需发货',//不发货,用户购买后就完成订单,可以直接看内容
+            ],
+        ],
+
+        'refund_status'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '退款申请状态',
+            'default'   => '2',
+            'value'         => [
+                1 => '退款申请中',
+                2 => '无退款申请',
+            ],
+        ],
+
+        'status'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'value'         => [
+                1 => '待支付',
+                2 => '待发货',
+                3 => '已发货',
+                4 => '待收货',
+                5 => '已完成',
+                6 => '已完成(有退款)',
+                7 => '已取消',
+                8 => '已退款',
+                9 => '已过期',
+            ],
+        ],
+
+        'pdate'       => [
+            'type'      => 'int(11)',
+            'name'      => '付款时间',
+        ],
+
+        'ddate'       => [
+            'type'      => 'int(11)',
+            'name'      => '发货时间',
+        ],
+
+        'qdate'       => [
+            'type'      => 'int(11)',
+            'name'      => '签收时间',
+        ],
+
+        'fdate'       => [
+            'type'      => 'int(11)',
+            'name'      => '完成时间',
+        ],
+    ],
+
+    'index' => [
+        'search' => 'uid,order_num',
+    ],
+];

+ 41 - 50
src/place/order/table/source_cart.php

@@ -1,50 +1,41 @@
-<?php
-return array
-(
-    'name' => '资源购物车',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'source_id' => array
-        (
-            'name'      => '资源ID',
-            'type'      => 'int(11)',
-        ),
-
-        'sku_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => 'skuID',
-        ),
-
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-
-        'price' => array
-        (
-            'name'      => '价格',
-            'type'      => 'decimal(11,2)',
-        ),
-
-        'num'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '数量',
-        ),
-
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '选中',
-                2 => '未选中',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源购物车',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'source_id' => [
+            'name'      => '资源ID',
+            'type'      => 'int(11)',
+        ],
+
+        'sku_id'        => [
+            'type'      => 'int(11)',
+            'name'      => 'skuID',
+        ],
+
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'price' => [
+            'name'      => '价格',
+            'type'      => 'decimal(11,2)',
+        ],
+
+        'num'      => [
+            'type'      => 'int(11)',
+            'name'      => '数量',
+        ],
+
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '选中',
+                2 => '未选中',
+            ],
+        ],
+    ],
+];

+ 65 - 79
src/place/order/table/source_detail.php

@@ -1,79 +1,65 @@
-<?php
-return array
-(
-    'name' => '资源支付订单明细表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'source_id' => array
-        (
-            'name'      => '资源ID',
-            'type'      => 'int(11)',
-        ),
-
-        'sku_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '价格ID',
-        ),
-
-        'order_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'name'      => array
-        (
-            'type'      => 'varchar(80)',
-            'name'      => '名称',
-        ),
-
-        'pic' => array
-        (
-            'name'      => '图片',
-            'type'      => 'varchar(150)',
-        ),
-
-        'sku_name'      => array
-        (
-            'type'      => 'varchar(200)',
-            'name'      => '价格的规格名称',
-        ),
-
-        'cash'      => array
-        (
-            'type'      => 'decimal(11,2)',
-            'name'      => '明细金额',
-        ),
-
-        'num'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '明细数量',
-        ),
-
-        'unum'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '使用次数',
-        ),
-
-        'status'        => array
-        (
-            'type'      => 'tinyint(1)',
-            'name'      => '明细状态',
-            'default'   => '1',
-            'value'         => array
-            (
-                1 => '正常',
-                2 => '部分退款',
-                3 => '已全部退款',
-            ),
-        ),
-    ),
-    'index' => array
-    (
-        'search' => 'order_id,source_id,sku_id',
-    ),
-);
+<?php
+return [
+    'name' => '资源支付订单明细表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'source_id' => [
+            'name'      => '资源ID',
+            'type'      => 'int(11)',
+        ],
+
+        'sku_id'        => [
+            'type'      => 'int(11)',
+            'name'      => '价格ID',
+        ],
+
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'name'      => [
+            'type'      => 'varchar(80)',
+            'name'      => '名称',
+        ],
+
+        'pic' => [
+            'name'      => '图片',
+            'type'      => 'varchar(150)',
+        ],
+
+        'sku_name'      => [
+            'type'      => 'varchar(200)',
+            'name'      => '价格的规格名称',
+        ],
+
+        'cash'      => [
+            'type'      => 'decimal(11,2)',
+            'name'      => '明细金额',
+        ],
+
+        'num'      => [
+            'type'      => 'int(11)',
+            'name'      => '明细数量',
+        ],
+
+        'unum'      => [
+            'type'      => 'int(11)',
+            'name'      => '使用次数',
+        ],
+
+        'status'        => [
+            'type'      => 'tinyint(1)',
+            'name'      => '明细状态',
+            'default'   => '1',
+            'value'         => [
+                1 => '正常',
+                2 => '部分退款',
+                3 => '已全部退款',
+            ],
+        ],
+    ],
+    'index' => [
+        'search' => 'order_id,source_id,sku_id',
+    ],
+];

+ 22 - 27
src/place/order/table/source_express.php

@@ -1,27 +1,22 @@
-<?php
-return array
-(
-    'name' => '资源订单物流配送表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'order_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'express_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '快递公司',
-            'value'     => 'sector/express',
-        ),
-
-        'number'      => array
-        (
-            'type'      => 'varchar(500)',
-            'name'      => '快递单号',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源订单物流配送表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'express_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '快递公司',
+            'value'     => 'sector/express',
+        ],
+
+        'number'      => [
+            'type'      => 'varchar(500)',
+            'name'      => '快递单号',
+        ],
+    ],
+];

+ 33 - 40
src/place/order/table/source_log.php

@@ -1,40 +1,33 @@
-<?php
-return array
-(
-    'name' => '资源订单日志表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'order_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'type' => array
-        (
-            'name'      => '操作人类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                -1 => '系统',
-                1 => '买家',
-                2 => '卖家',
-                3 => '渠道',
-            ),
-        ),
-
-        'type_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '操作人',
-        ),
-
-        'desc'      => array
-        (
-            'type'      => 'varchar(1000)',
-            'name'      => '操作明细',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源订单日志表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'type' => [
+            'name'      => '操作人类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                -1 => '系统',
+                1 => '买家',
+                2 => '卖家',
+                3 => '渠道',
+            ],
+        ],
+
+        'type_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '操作人',
+        ],
+
+        'desc'      => [
+            'type'      => 'varchar(1000)',
+            'name'      => '操作明细',
+        ],
+    ],
+];

+ 90 - 107
src/place/order/table/source_refund.php

@@ -1,107 +1,90 @@
-<?php
-return array
-(
-    'name' => '资源退款单表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'order_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'cash'      => array
-        (
-            'type'      => 'decimal(11,2)',
-            'name'      => '退款金额',
-        ),
-
-        'desc'      => array
-        (
-            'type'      => 'varchar(200)',
-            'name'      => '申请说明',
-        ),
-
-        'audit_desc'      => array
-        (
-            'type'      => 'varchar(200)',
-            'name'      => '审核备注',
-        ),
-
-        'type' => array
-        (
-            'name'      => '类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '退货退款',
-                2 => '仅退款',
-            ),
-        ),
-
-        'desc_type' => array
-        (
-            'name'      => '申请原因',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '不想要了',
-                2 => '不喜欢、效果不好',
-                3 => '货物与描述不符',
-                4 => '收到商品少件',
-                5 => '商品破损或污渍',
-                6 => '发错货',
-                7 => '假冒品牌',
-                8 => '其他原因',
-            ),
-        ),
-
-        'refund_status' => array
-        (
-            'name'      => '退款状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '退款有效',
-                2 => '退款无效',
-            ),
-        ),
-
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '申请中',
-                2 => '已审核',
-                3 => '已退货',
-                4 => '已退款',
-                5 => '已驳回',
-            ),
-        ),
-
-        'sdate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '审核时间',
-        ),
-
-        'ddate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '发货时间',
-        ),
-
-        'fdate'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '完成时间',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源退款单表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'cash'      => [
+            'type'      => 'decimal(11,2)',
+            'name'      => '退款金额',
+        ],
+
+        'desc'      => [
+            'type'      => 'varchar(200)',
+            'name'      => '申请说明',
+        ],
+
+        'audit_desc'      => [
+            'type'      => 'varchar(200)',
+            'name'      => '审核备注',
+        ],
+
+        'type' => [
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '退货退款',
+                2 => '仅退款',
+            ],
+        ],
+
+        'desc_type' => [
+            'name'      => '申请原因',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '不想要了',
+                2 => '不喜欢、效果不好',
+                3 => '货物与描述不符',
+                4 => '收到商品少件',
+                5 => '商品破损或污渍',
+                6 => '发错货',
+                7 => '假冒品牌',
+                8 => '其他原因',
+            ],
+        ],
+
+        'refund_status' => [
+            'name'      => '退款状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '退款有效',
+                2 => '退款无效',
+            ],
+        ],
+
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '申请中',
+                2 => '已审核',
+                3 => '已退货',
+                4 => '已退款',
+                5 => '已驳回',
+            ],
+        ],
+
+        'sdate'       => [
+            'type'      => 'int(11)',
+            'name'      => '审核时间',
+        ],
+
+        'ddate'       => [
+            'type'      => 'int(11)',
+            'name'      => '发货时间',
+        ],
+
+        'fdate'       => [
+            'type'      => 'int(11)',
+            'name'      => '完成时间',
+        ],
+    ],
+];

+ 31 - 38
src/place/order/table/source_refund_detail.php

@@ -1,38 +1,31 @@
-<?php
-return array
-(
-    'name' => '资源退款单明细表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'order_refund_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'detail_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '资源明细',
-        ),
-
-        'num'      => array
-        (
-            'type'      => 'decimal(11,2)',
-            'name'      => '退款数量',
-        ),
-
-        'refund_status' => array
-        (
-            'name'      => '退款状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '退款有效',
-                2 => '退款无效',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源退款单明细表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_refund_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'detail_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '资源明细',
+        ],
+
+        'num'      => [
+            'type'      => 'decimal(11,2)',
+            'name'      => '退款数量',
+        ],
+
+        'refund_status' => [
+            'name'      => '退款状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '退款有效',
+                2 => '退款无效',
+            ],
+        ],
+    ],
+];

+ 27 - 33
src/place/order/table/source_refund_express.php

@@ -1,33 +1,27 @@
-<?php
-return array
-(
-    'name' => '资源订单退货物流配送表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'order_refund_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '退款ID',
-        ),
-
-        'order_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'express_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '快递公司',
-            'value'     => 'sector/express',
-        ),
-
-        'number'      => array
-        (
-            'type'      => 'varchar(500)',
-            'name'      => '快递单号',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源订单退货物流配送表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_refund_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '退款ID',
+        ],
+
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'express_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '快递公司',
+            'value'     => 'sector/express',
+        ],
+
+        'number'      => [
+            'type'      => 'varchar(500)',
+            'name'      => '快递单号',
+        ],
+    ],
+];

+ 16 - 20
src/place/order/table/source_virtual.php

@@ -1,20 +1,16 @@
-<?php
-return array
-(
-    'name' => '资源虚拟信息表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'order_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '订单ID',
-        ),
-
-        'content'       => array
-        (
-            'type'      => 'varchar(500)',
-            'name'      => '虚拟信息',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '资源虚拟信息表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'order_id'       => [
+            'type'      => 'int(11)',
+            'name'      => '订单ID',
+        ],
+
+        'content'       => [
+            'type'      => 'varchar(500)',
+            'name'      => '虚拟信息',
+        ],
+    ],
+];

+ 39 - 48
src/place/order/table/user_source.php

@@ -1,48 +1,39 @@
-<?php
-return array
-(
-    'name' => '用户资源表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-
-        'source_id' => array
-        (
-            'name'      => '资源ID',
-            'type'      => 'int(11)',
-        ),
-
-        'sku_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '价格ID',
-        ),
-
-        'unum_total'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '总次数',
-        ),
-
-        'unum_used'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '使用次数',
-        ),
-
-        'unum_balance'      => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '剩余次数',
-        ),
-    ),
-    'index' => array
-    (
-        'search' => 'uid,source_id,sku_id',
-    ),
-);
+<?php
+return [
+    'name' => '用户资源表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+
+        'source_id' => [
+            'name'      => '资源ID',
+            'type'      => 'int(11)',
+        ],
+
+        'sku_id'        => [
+            'type'      => 'int(11)',
+            'name'      => '价格ID',
+        ],
+
+        'unum_total'      => [
+            'type'      => 'int(11)',
+            'name'      => '总次数',
+        ],
+
+        'unum_used'      => [
+            'type'      => 'int(11)',
+            'name'      => '使用次数',
+        ],
+
+        'unum_balance'      => [
+            'type'      => 'int(11)',
+            'name'      => '剩余次数',
+        ],
+    ],
+    'index' => [
+        'search' => 'uid,source_id,sku_id',
+    ],
+];

+ 58 - 71
src/place/order/table/user_source_log.php

@@ -1,71 +1,58 @@
-<?php
-return array
-(
-    'name' => '用户资源记录表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-        'source_id' => array
-        (
-            'name'      => '资源ID',
-            'type'      => 'int(11)',
-        ),
-
-        'sku_id'        => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '价格ID',
-        ),
-        'type' => array
-        (
-            'name'      => '类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '收入',
-                2 => '支出',
-            ),
-        ),
-        'source_type' => array
-        (
-            'name'      => '交易类型',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '购买资源增加次数',
-                2 => '查看内容消耗次数',
-
-                100 => '赠送',
-            ),
-        ),
-        'amount'        => array
-        (
-            'name'      => '变动次数',
-            'type'      => 'int(11)',
-        ),
-
-        'status' => array
-        (
-            'name'      => '入账状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '已入账',
-                2 => '待入账',
-            ),
-        ),
-    ),
-
-    'index' => array
-    (
-        'search' => 'uid,source_id,sku_id,type,source_type',
-    ),
-);
+<?php
+return [
+    'name' => '用户资源记录表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+        'source_id' => [
+            'name'      => '资源ID',
+            'type'      => 'int(11)',
+        ],
+
+        'sku_id'        => [
+            'type'      => 'int(11)',
+            'name'      => '价格ID',
+        ],
+        'type' => [
+            'name'      => '类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '收入',
+                2 => '支出',
+            ],
+        ],
+        'source_type' => [
+            'name'      => '交易类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '购买资源增加次数',
+                2 => '查看内容消耗次数',
+
+                100 => '赠送',
+            ],
+        ],
+        'amount'        => [
+            'name'      => '变动次数',
+            'type'      => 'int(11)',
+        ],
+
+        'status' => [
+            'name'      => '入账状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '已入账',
+                2 => '待入账',
+            ],
+        ],
+    ],
+
+    'index' => [
+        'search' => 'uid,source_id,sku_id,type,source_type',
+    ],
+];

+ 179 - 0
src/place/role/lib/Info.php

@@ -0,0 +1,179 @@
+<?php namespace Place_role\Lib;
+use Dever;
+class Info
+{
+    public function getData($id)
+    {
+        $data['role'] = $this->getInfo($id);
+        $data['user'] = Dever::load('user', 'place_role')->getInfo($id);
+        if ($data['user']['level_id'] > 0) {
+            $data['role']['info'] = $data['user']['sign'];
+        }
+        $data['level'] = $this->getList($id, $data['user'], $data['role']['score']);
+        return $data;
+    }
+
+    # 获取角色信息
+    public function getInfo($id)
+    {
+        $info = Dever::db('info', 'place_role')->find(['id' => $id, 'status' => 1], ['col' => 'id,name,info,score_id']);
+        if (!$info) {
+            Dever::error('角色信息错误');
+        }
+        $info['score'] = Dever::db('info', 'place_score')->find($info['score_id'], ['col' => 'id,exp,name,symbol,symbol_location']);
+        $info['rebate'] = Dever::load('rebate', 'place_score')->get(4, $info['id']);
+        return $info;
+    }
+
+    # 获取等级列表
+    public function getList($info_id, $user, $score)
+    {
+        $result = [];
+        $where['info_id'] = $info_id;
+        if ($user['level'] > 0) {
+            $where['level'] = ['>=', $user['level']];
+        }
+        $where['status'] = 1;
+        $data = Dever::db('level', 'place_role')->select($where, ['col' => 'id,info_id,name,info,level,price,day,pay']);
+        if ($data) {
+            foreach ($data as $v) {
+                if ($user['level_id'] > 0 && $v['id'] != $user['level_id'] && $v['pay'] == 1) {
+                    $v['price'] -= $user['price'];
+                }
+                $v['active'] = 0;
+                if ($v['day'] > 0) {
+                    $v['day_desc'] = $v['day'] . '天';
+                } else {
+                    $v['day_desc'] = '永久';
+                }
+                
+                # 获取权益
+                $v['price_text'] = Dever::load('info', 'place_score')->getText($v['price'], $score);
+                $v['profit_buy'] = $this->getProfitBuy($v['id']);
+                if ($v['profit_buy']) {
+                    $v['profit'][] = '购买权益';
+                }
+                $v['profit_sale'] = $this->getProfitSale($v['id']);
+                if ($v['profit_sale']) {
+                    $v['profit'][] = '分销权益';
+                }
+                $v['profit_partner'] = $this->getProfitPartner($v['id']);
+                if ($v['profit_partner']) {
+                    $v['profit'][] = '分成权益';
+                }
+                if (isset($v['profit']) && $v['profit']) {
+                    $result[] = $v;
+                }
+            }
+        }
+        return $result;
+    }
+
+    # 获取权益
+    public function getProfitBuy($id)
+    {
+        $result = [];
+        $profit = Dever::db('profit_buy', 'place_role')->select(['level_id' => $id, 'status' => 1]);
+        if ($profit) {
+            foreach ($profit as $v) {
+                if ($v['type']) {
+                    $name = $this->getProfitName($v['type']);
+                    if ($name) {
+                        $desc = [];
+                        if ($v['discount'] > 0) {
+                            $desc[] = $this->getDesc('购买折扣', $v['discount'] . '折');
+                        } elseif ($v['discount'] <= 0) {
+                            $desc[] = $this->getDesc('购买价格', '免费');
+                        }
+                        if ($v['rebate'] > 0) {
+                            $desc[] = $this->getDesc('积分返利倍数', $v['rebate'] . '倍');
+                        }
+                        if ($v['limit'] > 0) {
+                            $desc[] = $this->getDesc('每日下载次数', $v['limit'] . '次');
+                        }
+                        if ($desc) {
+                            $result[] = ['name' => $name, 'desc' => $desc];
+                        }
+                    }
+                }
+            }
+        }
+        return $result;
+    }
+
+    # 获取权益
+    public function getProfitSale($id)
+    {
+        $result = [];
+        $profit = Dever::db('profit_sale', 'place_role')->select(['level_id' => $id, 'status' => 1]);
+        if ($profit) {
+            foreach ($profit as $v) {
+                if ($v['type'] && $v['percent'] > 0 && $v['score_id']) {
+                    $name = $this->getProfitName($v['type']);
+                    if ($name) {
+                        $desc = [];
+                        $score = Dever::db('info', 'place_score')->find($v['score_id'], ['col' => 'id,name']);
+                        $desc[] = $this->getDesc('佣金账户', $score['name']);
+                        $desc[] = $this->getDesc('佣金比例', $v['percent'] . '%售价');
+                        $result[] = ['name' => $name, 'desc' => $desc];
+                    }
+                }
+            }
+        }
+        return $result;
+    }
+
+    # 获取权益
+    public function getProfitPartner($id)
+    {
+        $result = [];
+        $profit = Dever::db('profit_partner', 'place_role')->select(['level_id' => $id, 'status' => 1]);
+        if ($profit) {
+            foreach ($profit as $v) {
+                if ($v['type'] && $v['percent'] > 0 && $v['score_id']) {
+                    $name = $this->getProfitName($v['type']);
+                    if ($name) {
+                        $desc = [];
+                        $score = Dever::db('info', 'place_score')->find($v['score_id'], ['col' => 'id,name']);
+                        if ($v['period'] == 1) {
+                            $period_day = $v['period_day'].'点';
+                        } elseif ($v['period'] == 2) {
+                            $period_day = '每周'.$v['period_day'].'凌晨1点';
+                        } elseif ($v['period'] == 3) {
+                            $period_day = '每月'.$v['period_day'].'号凌晨1点';
+                        } elseif ($v['period'] == 4) {
+                            $period_day = '每季度第'.$v['period_day'].'天凌晨1点';
+                        } elseif ($v['period'] == 5) {
+                            $period_day = '每年第'.$v['period_day'].'天凌晨1点';
+                        }
+                        $period = Dever::db('profit_partner', 'place_role')->value('period', $v['period']);
+                        $desc[] = $this->getDesc('结算周期', $period);
+                        $desc[] = $this->getDesc('结算时间', $period_day);
+                        $desc[] = $this->getDesc('结算账户', $score['name']);
+                        $desc[] = $this->getDesc('结算比例', $v['percent'] . '%利润');
+                        $result[] = ['name' => $name, 'desc' => $desc];
+                    }
+                }
+            }
+        }
+        return $result;
+    }
+
+    # 获取权益信息
+    public function getProfitName($type)
+    {
+        list($type, $type_id) = explode(',', $type);
+        $name = '';
+        if ($type == 1) {
+            $name = Dever::db('channel', 'place_source')->column($type_id);
+        } elseif ($type == 2) {
+            $name = Dever::db('info', 'place_role')->column($type_id);
+        }
+        return $name;
+    }
+
+    private function getDesc($name, $info)
+    {
+        return ['name' => $name, 'info' => $info];
+    }
+}

+ 99 - 0
src/place/role/lib/User.php

@@ -0,0 +1,99 @@
+<?php namespace Place_role\Lib;
+use Dever;
+use Place;
+class User
+{
+    public function getInfo($id)
+    {
+        $user = [
+            'logo' => Place::$info['logo'],
+            'sign' => '',
+            'level_id' => 0,
+            'level' => 0,
+            'price' => 0,
+            'name' => '去登录',
+            'title' => '立即开通',
+            'info' => '',
+            'card' => '开通立享权益',
+            'button' => '立即开通',
+        ];
+        if (Place::$uid) {
+            $user['logo'] = Place::$user['avatar'];
+            $user['name'] = Place::$user['name'];
+            $user['sign'] = Place::$user['sign'];
+            $info = Dever::db('user', 'place_role')->find(['uid' => Place::$uid, 'info_id' => $id]);
+            if ($info) {
+                if ($info['edate'] > time()) {
+                    $level = Dever::db('level', 'place_role')->find(['id' => $info['level_id'], 'status' => 1]);
+                    if ($level) {
+                        $user['card'] = $info['card'];
+                        $user['level_id'] = $level['id'];
+                        $user['level'] = $level['level'];
+                        $user['price'] = $level['price'];
+                        $user['title'] = $level['name'];
+                        $user['button'] = '立即续费';
+                        if ($info['edate']) {
+                            $user['info'] = date('Y/m/d', $info['edate']) . '到期'; 
+                        } else {
+                            $user['info'] = '永久有效'; 
+                        }
+                    } else {
+                        Dever::db('role', 'place_user')->update($info['id'], ['status' => 2]);
+                    }
+                } else {
+                    # 已过期
+                    Dever::db('role', 'place_user')->update($info['id'], ['status' => 2]);
+                }
+            }
+        }
+        return $user;
+    }
+
+    # 获取账户信息
+    public function get($uid, $id)
+    {
+        $user = Dever::db('user', 'place_role')->find(['uid' => $uid, 'info_id' => $id]);
+        if ($user) {
+            return $user['balance'];
+        }
+        return 0;
+    }
+
+    # 获取账户列表
+    public function getList($uid)
+    {
+        $user = Dever::db('user', 'place_role')->kv(['uid' => $uid], ['kv' => ['info_id', 'level_id']]);
+        if ($user) {
+            foreach ($user as &$v) {
+                $level = Dever::db('level', 'place_role')->find($v);
+                $v = $level['name'];
+            }
+        }
+        return $user;
+    }
+
+    # 更新账户信息
+    public function up($uid, $role_id, $level_id)
+    {
+        $data = ['uid' => $uid, 'info_id' => $role_id];
+        $user = Dever::db('user', 'place_role')->find($data);
+        $info = Dever::db('level', 'place_role')->find($level_id);
+        if ($info) {
+            $data['level_id'] = $info['id'];
+            $data['edate'] = $info['day']*86400;
+            $date = time();
+            if ($user) {
+                if ($user['status'] == 2 || $user['edate'] <= $date) {
+                    $data['edate'] += $date;
+                } else {
+                    $data['edate'] += $user['edate'];
+                }
+                return Dever::db('user', 'place_role')->update($user['id'], $data);
+            } else {
+                $data['edate'] += $date;
+                $data['card'] = Dever::load('util', 'api')->createNumber('', 'place_role/user', [], 'card');
+                return Dever::db('user', 'place_role')->insert($data);
+            }
+        }
+    }
+}

+ 22 - 22
src/place/role/manage/Lib/Api.php

@@ -1,23 +1,23 @@
-<?php namespace Place_role\Manage\Lib;
-use Dever;
-class Api
-{
-    public function test()
-    {
-        return Dever::$data['muser'];
-    }
-    public function getRoleLevel($value)
-    {
-        if (is_array($value)) {
-            $value = end($value);
-        }
-        $result = array();
-        $result['level_id']['value'] = '';
-        if (!$value) {
-            $result['level_id']['option'] = array();
-            return $result;
-        }
-        $result['level_id']['option'] = Dever::db('level', 'place_role')->select(array('info_id' => $value));
-        return $result;
-    }
+<?php namespace Place_role\Manage\Lib;
+use Dever;
+class Api
+{
+    public function test()
+    {
+        return Dever::$data['muser'];
+    }
+    public function getRoleLevel($value)
+    {
+        if (is_[$value]) {
+            $value = end($value);
+        }
+        $result = [];
+        $result['level_id']['value'] = '';
+        if (!$value) {
+            $result['level_id']['option'] = [];
+            return $result;
+        }
+        $result['level_id']['option'] = Dever::db('level', 'place_role')->select(['info_id' => $value]);
+        return $result;
+    }
 }

+ 1 - 1
src/place/role/manage/Lib/Data.php

@@ -4,7 +4,7 @@ class Data
 {
     public function getList()
     {
-        $result = array();
+        $result = [];
         $set = ['col' => 'id as value,name as label'];
         $role = Dever::db('info', 'place_role')->select(['status' => 1], $set);
         foreach ($role as $k => $v) {

+ 27 - 32
src/place/role/manage/core.php

@@ -1,32 +1,27 @@
-<?php
-return array
-(
-    'menu' => array
-    (
-        # 某个账户下角色设置
-        'set_role_manage' => array
-        (
-            'parent'    => 'sector_place_set',
-            'name'      => '角色配置',
-            'icon'      => 'folder-user-line',
-            'sort'      => '101',
-        ),
-
-        'info' => array
-        (
-            'parent'    => 'set_role_manage',
-            'name'      => '角色管理',
-            'icon'      => 'user-2-line',
-            'sort'      => '1',
-        ),
-
-        'level' => array
-        (
-            'parent'    => 'set_role_manage',
-            'name'      => '角色等级',
-            'icon'      => 'user-2-line',
-            'sort'      => '1',
-            'show'      => 3,
-        ),
-    ),
-);
+<?php
+return [
+    'menu' => [
+        # 某个账户下角色设置
+        'set_role_manage' => [
+            'parent'    => 'sector_place_set',
+            'name'      => '角色配置',
+            'icon'      => 'folder-user-line',
+            'sort'      => '101',
+        ],
+
+        'info' => [
+            'parent'    => 'set_role_manage',
+            'name'      => '角色管理',
+            'icon'      => 'user-2-line',
+            'sort'      => '1',
+        ],
+
+        'level' => [
+            'parent'    => 'set_role_manage',
+            'name'      => '角色等级',
+            'icon'      => 'user-2-line',
+            'sort'      => '1',
+            'show'      => 3,
+        ],
+    ],
+];

+ 53 - 65
src/place/role/manage/info.php

@@ -1,65 +1,53 @@
-<?php
-return array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'name',
-            'score_id',
-            'sort' => array
-            (
-                'type' => 'input',
-                'tips' => '双击修改排序,正序排序',
-            ),
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-        'button' => array
-        (
-            '新增' => array('fastadd'),
-        ),
-        'data_button' => array
-        (
-            '编辑' => 'fastedit',
-            '等级设置' => array('route', array
-            (
-                'path' => 'set_role_manage/level',
-                'param' => array
-                (
-                    'set' => array('info_id' => 'id', 'menu' => 'set_role_manage/info', 'parent' => 'set_role_manage/info'),
-                ),
-            )),
-        ),
-        'search'    => array
-        (
-            'name',
-        ),
-    ),
-    'update' => array
-    (
-        'field'    => array
-        (
-            'name' => array
-            (
-                'rules' => true,
-            ),
-            'score_id' => array
-            (
-                'rules' => true,
-                'tips' => '购买该角色所需的积分',
-            ),
-            'place_score/rebate' => array
-            (
-                'name' => '返利积分',
-                'tips' => '选择返利积分后,当用户购买该角色后,将按照规则返利',
-                'where'  => array('type' => 4,'type_id' => 'id'),
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'list' => [
+        'field'      => [
+            'name',
+            'score_id',
+            'sort' => [
+                'type' => 'input',
+                'tips' => '双击修改排序,正序排序',
+            ],
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'button' => [
+            '新增' => ['fastadd'],
+        ],
+        'data_button' => [
+            '编辑' => 'fastedit',
+            '等级设置' => ['route', [
+                'path' => 'set_role_manage/level',
+                'param' => [
+                    'set' => ['info_id' => 'id', 'menu' => 'set_role_manage/info', 'parent' => 'set_role_manage/info'],
+                ],
+            ]],
+        ],
+        'search'    => [
+            'name',
+        ],
+    ],
+    'update' => [
+        'field'    => [
+            'name' => [
+                'rules' => true,
+            ],
+            'info' => [
+                'rules' => true,
+            ],
+            'score_id' => [
+                'rules' => true,
+                'tips' => '购买该角色所需的积分',
+            ],
+            'place_score/rebate' => [
+                'name' => '返利积分',
+                'tips' => '选择返利积分后,当用户购买该角色后,将按照规则返利',
+                'where'  => ['type' => 4,'type_id' => 'id'],
+            ],
+        ],
+    ],
+];

+ 74 - 103
src/place/role/manage/level.php

@@ -1,103 +1,74 @@
-<?php
-$info_id = Dever::input('set')['info_id'] ?? 0;
-return array
-(
-    'list' => array
-    (
-        'where' => array('info_id' => $info_id),
-        'field'      => array
-        (
-            'name',
-            'level',
-            'price',
-            'day_desc',
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-        'button' => array
-        (
-            '新增' => array('add', array('info_id' => $info_id)),
-        ),
-        'data_button' => array
-        (
-            '编辑' => array('edit', array('info_id' => $info_id)),
-        ),
-        'search'    => array
-        (
-            'name',
-            'info_id' => 'hidden',
-        ),
-    ),
-    'update' => array
-    (
-        'tab' => array
-        (
-            '基本信息' => 'name,level,price,pay,day_desc,day,content',
-            '权益设置' => 'place_role/profit_buy,place_role/profit_sale,place_role/profit_partner',
-        ),
-        'field'    => array
-        (
-            'info_id',
-            'name' => array
-            (
-                'rules' => true,
-            ),
-            'level' => array
-            (
-                'rules' => true,
-                'desc' => '将按照等级数字正序排序',
-            ),
-            'price' => array
-            (
-                'rules' => true,
-                'tips' => '购买当前等级所需支付的积分金额,填写0则免费',
-            ),
-            'pay' => array
-            (
-                'type' => 'radio',
-                'rules' => true,
-                'tips' => '差额支付:如用户已是等级1,购买等级2时会自动减去等级1已支付的金额<br />全额支付:根据价格全额支付',
-            ),
-            'day_desc' => array
-            (
-                'rules' => true,
-                'desc' => '设置时长名称,如一年',
-            ),
-            'day' => array
-            (
-                'rules' => true,
-                'desc' => '设置时长天数,如365,如果填写-1就是永久有效',
-            ),
-            /*
-            'content' => array
-            (
-                'type' => 'editor',
-                'editorMenu' => array
-                (
-                    'uploadImage' => 1,
-                    'uploadVideo' => 3,
-                ),
-            ),*/
-            'place_role/profit_buy' => array
-            (
-                'name' => '购买权益',
-                'where'  => array('level_id' => 'id'),
-            ),
-            'place_role/profit_sale' => array
-            (
-                'name' => '分销佣金',
-                'where'  => array('level_id' => 'id'),
-            ),
-            'place_role/profit_partner' => array
-            (
-                'name' => '合作分成',
-                'where'  => array('level_id' => 'id'),
-            ),
-        ),
-    ),
-);
+<?php
+$info_id = Dever::input('set')['info_id'] ?? 0;
+return [
+    'list' => [
+        'where' => ['info_id' => $info_id],
+        'field'      => [
+            'name',
+            'level',
+            'price',
+            'day',
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'button' => [
+            '新增' => ['add', ['info_id' => $info_id]],
+        ],
+        'data_button' => [
+            '编辑' => ['edit', ['info_id' => $info_id]],
+        ],
+        'search'    => [
+            'name',
+            'info_id' => 'hidden',
+        ],
+    ],
+    'update' => [
+        'tab' => [
+            '基本信息' => 'name,level,info,price,pay,day,content',
+            '权益设置' => 'place_role/profit_buy,place_role/profit_sale,place_role/profit_partner',
+        ],
+        'field'    => [
+            'info_id',
+            'name' => [
+                'rules' => true,
+            ],
+            'info' => [
+                //'rules' => true,
+            ],
+            'level' => [
+                'rules' => true,
+                'desc' => '将按照等级数字正序排序',
+            ],
+            'price' => [
+                'rules' => true,
+                'tips' => '购买当前等级所需支付的积分金额,填写0则免费',
+            ],
+            'pay' => [
+                'type' => 'radio',
+                'rules' => true,
+                'tips' => '差额支付:如用户已是等级1,购买等级2时会自动减去等级1已支付的金额<br />全额支付:根据价格全额支付',
+            ],
+            'day' => [
+                'rules' => true,
+                'desc' => '设置时长天数,如365,如果填写-1就是永久有效',
+            ],
+            
+            'place_role/profit_buy' => [
+                'name' => '购买权益',
+                'where'  => ['level_id' => 'id'],
+            ],
+            'place_role/profit_sale' => [
+                'name' => '分销佣金',
+                'where'  => ['level_id' => 'id'],
+            ],
+            'place_role/profit_partner' => [
+                'name' => '合作分成',
+                'where'  => ['level_id' => 'id'],
+            ],
+        ],
+    ],
+];

+ 37 - 36
src/place/role/manage/profit_buy.php

@@ -1,36 +1,37 @@
-<?php
-return array
-(
-    'update' => array
-    (
-        'field'    => array
-        (
-            'type' => array
-            (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("place/manage/profit.getInfo")',
-            ),
-            'discount' => array
-            (
-                'tips' => '购买当前权益的折扣,直接填写数字即可,填写9就是9折
-                    <br />权益当前价格*(购买折扣/10)=权益实付价格
-                    <br />如:此处购买折扣填写为8,则权益实付价格=权益当前价格*(8/10)
-                    <br />不填写则无折扣,填写0则免费',
-                'placeholder' => '权益当前价格*(购买折扣/10)=权益实付价格',
-            ),
-            'limit' => array
-            (
-                'tips' => '填写每日上限数值,不填写不限制<br />该限制为查看收费内容或功能的次数<br />如填写100,则每日只能查看100次,一般适合长期会员',
-                'placeholder' => '填写每日上限数值',
-            ),
-            'status' => array
-            (
-                'width' => '40',
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'update' => [
+        'field'    => [
+            'type' => [
+                'type' => 'cascader',
+                'option'    => 'Dever::call("place/manage/profit.getInfo", false)',
+            ],
+            'discount' => [
+                'tips' => '购买当前权益的折扣,直接填写数字即可,填写9就是9折
+                    <br />权益当前价格*(购买折扣/10)=权益实付价格
+                    <br />如:此处购买折扣填写为8,则权益实付价格=权益当前价格*(8/10)
+                    <br />不填写则无折扣,填写0则免费',
+                'placeholder' => '权益当前价格*(购买折扣/10)=权益实付价格',
+            ],
+            'rebate' => [
+                'tips' => '如果购买当前权益有设置返利,这里可以设置返利倍数
+                    <br />返利积分*返利倍数=实际返利积分
+                    <br />如:此处返利倍数填写为2,则实际返利积分=权益返利积分*2
+                    <br />这里也可以设置小于1的倍数,作为惩罚机制',
+                'placeholder' => '返利积分*返利倍数=权益返利积分',
+            ],
+            'limit' => [
+                'tips' => '填写每日上限数值,不填写不限制<br />该限制为每天查看收费内容或使用收费功能的次数<br />如填写100,则每天只能查看100次,一般适合长期会员',
+                'placeholder' => '填写每天上限数值',
+            ],
+            'status' => [
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'drag' => 'sort',
+    ],
+];

+ 42 - 46
src/place/role/manage/profit_partner.php

@@ -1,46 +1,42 @@
-<?php
-return array
-(
-    'update' => array
-    (
-        'field'    => array
-        (
-            'type' => array
-            (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("place/manage/profit.getInfo")',
-            ),
-            'period' => array
-            (
-                'type' => 'select',
-                'tips' => '选择结算周期,将按照周期结算代理分成',
-            ),
-            'period_day' => array
-            (
-                'type' => 'text',
-                'tips' => '输入结算时间,如输入2
-                    <br />结算周期选择按天时,就是每天2点结算昨天数据
-                    <br />结算周期选择按周时,就是每周星期2凌晨1点结算前一周数据
-                    <br />结算周期选择按月时,就是每月2号凌晨1点结算上个月数据
-                    <br />结算周期选择按季时,就是每季度第2天凌晨1点结算上一季度数据
-                    <br />结算周期选择按年时,就是每年第2天凌晨1点结算上一年数据',
-            ),
-            'percent' => array
-            (
-                'tips' => '代理团队周期内当前权益所产生的利润的分成比例,直接填写数字即可
-                    <br />周期内利润*分成比例%=分成
-                    <br />如:此处分成比例填写为10,则分成=周期内利润*10%
-                    <br />不填写则无分成',
-                'placeholder' => '周期内利润*分成比例%=分成',
-            ),
-            'status' => array
-            (
-                'width' => '40',
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'update' => [
+        'field'    => [
+            'type' => [
+                'type' => 'cascader',
+                'option'    => 'Dever::call("place/manage/profit.getInfo", false)',
+            ],
+            'period' => [
+                'type' => 'select',
+                'tips' => '选择结算周期,将按照周期结算代理分成',
+            ],
+            'period_day' => [
+                'type' => 'text',
+                'tips' => '输入结算时间,如输入2
+                    <br />结算周期选择按天时,就是每天2点结算昨天数据
+                    <br />结算周期选择按周时,就是每周星期2凌晨1点结算前一周数据
+                    <br />结算周期选择按月时,就是每月2号凌晨1点结算上个月数据
+                    <br />结算周期选择按季时,就是每季度第2天凌晨1点结算上一季度数据
+                    <br />结算周期选择按年时,就是每年第2天凌晨1点结算上一年数据',
+            ],
+            'score_id' => [
+                'type' => 'select',
+                'tips' => '选择发放分成的积分',
+            ],
+            'percent' => [
+                'tips' => '代理团队周期内当前权益所产生的利润的分成比例,直接填写数字即可
+                    <br />周期内利润*分成比例%=分成
+                    <br />如:此处分成比例填写为10,则分成=周期内利润*10%
+                    <br />不填写则无分成',
+                'placeholder' => '周期内利润*分成比例%=分成',
+            ],
+            'status' => [
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+    ],
+];

+ 30 - 37
src/place/role/manage/profit_sale.php

@@ -1,37 +1,30 @@
-<?php
-return array
-(
-    'update' => array
-    (
-        //'end' => 'place/manage/profit.update',
-        'field'    => array
-        (
-            'type' => array
-            (
-                'type' => 'cascader',
-                'option'    => 'Dever::call("place/manage/profit.getInfo")',
-            ),
-            'score_id' => array
-            (
-                'type' => 'select',
-                'tips' => '选择发放佣金的积分',
-            ),
-            'percent' => array
-            (
-                'tips' => '邀请他人购买当前权益可以获得的佣金,直接填写数字即可
-                    <br />权益实付价格*佣金比例%=佣金
-                    <br />如:此处佣金比例填写为10,则佣金=权益实付价格*10%
-                    <br />不填写则无佣金',
-                'placeholder' => '权益实付价格*佣金比例%=佣金',
-            ),
-            'status' => array
-            (
-                'width' => '40',
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'update' => [
+        //'end' => 'place/manage/profit.update',
+        'field'    => [
+            'type' => [
+                'type' => 'cascader',
+                'option'    => 'Dever::call("place/manage/profit.getInfo", false)',
+            ],
+            'score_id' => [
+                'type' => 'select',
+                'tips' => '选择发放佣金的积分',
+            ],
+            'percent' => [
+                'tips' => '邀请他人购买当前权益可以获得的佣金,直接填写数字即可
+                    <br />权益实付价格*佣金比例%=佣金
+                    <br />如:此处佣金比例填写为10,则佣金=权益实付价格*10%
+                    <br />不填写则无佣金',
+                'placeholder' => '权益实付价格*佣金比例%=佣金',
+            ],
+            'status' => [
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+    ],
+];

+ 40 - 44
src/place/role/table/info.php

@@ -1,44 +1,40 @@
-<?php
-return array
-(
-    'name' => '角色表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc,id asc',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '角色名称',
-            'type'      => 'varchar(32)',
-        ),
-        'desc' => array
-        (
-            'name'      => '介绍',
-            'type'      => 'varchar(800)',
-        ),
-        'score_id'        => array
-        (
-            'name'      => '购买积分',
-            'type'      => 'int(11)',
-            'value'     => 'place_score/info',
-            'default'   => '1',
-        ),
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '开启',
-                2 => '禁用',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '角色表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc,id asc',
+    'struct' => [
+        'name' => [
+            'name'      => '角色名称',
+            'type'      => 'varchar(32)',
+        ],
+        'info' => [
+            'name'      => '介绍',
+            'type'      => 'varchar(100)',
+        ],
+        'desc' => [
+            'name'      => '详情',
+            'type'      => 'varchar(800)',
+        ],
+        'score_id'        => [
+            'name'      => '购买积分',
+            'type'      => 'int(11)',
+            'value'     => 'place_score/info',
+            'default'   => '1',
+        ],
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '开启',
+                2 => '禁用',
+            ],
+        ],
+    ],
+];

+ 58 - 76
src/place/role/table/level.php

@@ -1,76 +1,58 @@
-<?php
-return array
-(
-    'name' => '角色等级设置',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'level asc,id asc',
-    'struct' => array
-    (
-        'info_id'        => array
-        (
-            'name'      => '角色ID',
-            'type'      => 'int(11)',
-        ),
-
-        'name' => array
-        (
-            'name'      => '等级名称',
-            'type'      => 'varchar(32)',
-        ),
-
-        'level' => array
-        (
-            'name'      => '等级数字',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-
-        'price' => array
-        (
-            'name'      => '等级价格',
-            'type'      => 'decimal(11,2)',
-        ),
-
-        'day' => array
-        (
-            'name'      => '时长天数',
-            'type'      => 'int(11)',
-        ),
-
-        'day_desc' => array
-        (
-            'name'      => '时长名称',
-            'type'      => 'varchar(32)',
-        ),
-
-        'pay' => array
-        (
-            'name'      => '升级方式',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '差额支付',
-                2 => '全额支付',
-            ),
-        ),
-
-        'content' => array
-        (
-            'name'      => '等级介绍',
-            'type'      => 'varchar(2000)',
-        ),
-        
-        'status' => array
-        (
-            'name'      => '等级状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '开启',
-                2 => '禁用',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '角色等级设置',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'level asc,id asc',
+    'struct' => [
+        'info_id'        => [
+            'name'      => '角色ID',
+            'type'      => 'int(11)',
+        ],
+
+        'name' => [
+            'name'      => '等级名称',
+            'type'      => 'varchar(32)',
+        ],
+
+        'info' => [
+            'name'      => '等级介绍',
+            'type'      => 'varchar(2000)',
+        ],
+
+        'level' => [
+            'name'      => '等级数字',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+
+        'price' => [
+            'name'      => '等级价格',
+            'type'      => 'decimal(11,2)',
+        ],
+
+        'day' => [
+            'name'      => '时长天数',
+            'type'      => 'int(11)',
+        ],
+
+        'pay' => [
+            'name'      => '升级方式',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '差额支付',
+                2 => '全额支付',
+            ],
+        ],
+        
+        'status' => [
+            'name'      => '等级状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '开启',
+                2 => '禁用',
+            ],
+        ],
+    ],
+];

+ 52 - 53
src/place/role/table/profit_buy.php

@@ -1,53 +1,52 @@
-<?php
-return array
-(
-    'name' => '角色等级购买权益设置表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc,id asc',
-    'struct' => array
-    (
-        'level_id' => array
-        (
-            'name'      => '角色等级id',
-            'type'      => 'int(11)',
-        ),
-
-        # 选择的权益类型 如果是资源 则可以选择频道 如果是角色 则可以选择角色
-        'type' => array
-        (
-            'name'      => '权益',
-            'type'      => 'varchar(100)',
-        ),
-
-        'discount' => array
-        (
-            'name'      => '购买折扣',
-            'type'      => 'decimal(11,1)',
-        ),
-
-        'limit' => array
-        (
-            'name'      => '上限',
-            'type'      => 'int(11)',
-        ),
-
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-        
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '开启',
-                2 => '禁用',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '角色等级购买权益设置表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc,id asc',
+    'struct' => [
+        'level_id' => [
+            'name'      => '角色等级id',
+            'type'      => 'int(11)',
+        ],
+
+        # 选择的权益类型 如果是资源 则可以选择频道 如果是角色 则可以选择角色
+        'type' => [
+            'name'      => '权益',
+            'type'      => 'varchar(100)',
+        ],
+
+        'discount' => [
+            'name'      => '购买折扣',
+            'type'      => 'decimal(11,1)',
+        ],
+
+        'rebate' => [
+            'name'      => '返利倍数',
+            'type'      => 'decimal(11,1)',
+        ],
+
+        'limit' => [
+            'name'      => '上限',
+            'type'      => 'int(11)',
+        ],
+
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+        
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '开启',
+                2 => '禁用',
+            ],
+        ],
+    ],
+    'index' => [
+        'search' => 'type,level_id,discount',
+    ],
+];

+ 67 - 69
src/place/role/table/profit_partner.php

@@ -1,69 +1,67 @@
-<?php
-return array
-(
-    'name' => '角色等级利润分成权益设置表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc,id asc',
-    'struct' => array
-    (
-        'level_id' => array
-        (
-            'name'      => '角色等级id',
-            'type'      => 'int(11)',
-        ),
-
-        # 选择的权益类型 如果是资源 则可以选择频道 如果是角色 则可以选择角色
-        'type' => array
-        (
-            'name'      => '权益',
-            'type'      => 'varchar(100)',
-        ),
-
-        'percent' => array
-        (
-            'name'      => '分成比例',
-            'type'      => 'decimal(11,1)',
-        ),
-
-        'period' => array
-        (
-            'name'      => '结算周期',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '每天',
-                2 => '每周',
-                3 => '每月',
-                4 => '每季',
-                4 => '每年',
-            ),
-        ),
-
-        'period_day' => array
-        (
-            'name'      => '结算时间',
-            'type'      => 'int(11)',
-            'default'   => '1',
-        ),
-
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-        
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '开启',
-                2 => '禁用',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '角色等级利润分成权益设置表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc,id asc',
+    'struct' => [
+        'level_id' => [
+            'name'      => '角色等级id',
+            'type'      => 'int(11)',
+        ],
+
+        # 选择的权益类型 如果是资源 则可以选择频道 如果是角色 则可以选择角色
+        'type' => [
+            'name'      => '权益',
+            'type'      => 'varchar(100)',
+        ],
+
+        'score_id'        => [
+            'name'      => '分成积分',
+            'type'      => 'int(11)',
+            'value'     => 'place_score/info',
+        ],
+
+        'percent' => [
+            'name'      => '分成比例',
+            'type'      => 'decimal(11,1)',
+        ],
+
+        'period' => [
+            'name'      => '结算周期',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '每天',
+                2 => '每周',
+                3 => '每月',
+                4 => '每季',
+                4 => '每年',
+            ],
+        ],
+
+        'period_day' => [
+            'name'      => '结算时间',
+            'type'      => 'int(11)',
+            'default'   => '1',
+        ],
+
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+        
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '开启',
+                2 => '禁用',
+            ],
+        ],
+    ],
+    'index' => [
+        'search' => 'type,level_id,percent',
+    ],
+];

+ 48 - 54
src/place/role/table/profit_sale.php

@@ -1,54 +1,48 @@
-<?php
-return array
-(
-    'name' => '角色等级销售佣金权益设置表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'order' => 'sort asc,id asc',
-    'struct' => array
-    (
-        'level_id' => array
-        (
-            'name'      => '角色等级id',
-            'type'      => 'int(11)',
-        ),
-
-        # 选择的权益类型 如果是资源 则可以选择频道 如果是角色 则可以选择角色
-        'type' => array
-        (
-            'name'      => '权益',
-            'type'      => 'varchar(100)',
-        ),
-
-        'score_id'        => array
-        (
-            'name'      => '佣金积分',
-            'type'      => 'int(11)',
-            'value'     => 'place_score/info',
-        ),
-
-        'percent' => array
-        (
-            'name'      => '佣金比例',
-            'type'      => 'decimal(11,1)',
-        ),
-
-        'sort' => array
-        (
-            'name'      => '排序',
-            'type'      => 'int(11)',
-            'default'   => 1,
-        ),
-        
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '开启',
-                2 => '禁用',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '角色等级销售佣金权益设置表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sort asc,id asc',
+    'struct' => [
+        'level_id' => [
+            'name'      => '角色等级id',
+            'type'      => 'int(11)',
+        ],
+
+        # 选择的权益类型 如果是资源 则可以选择频道 如果是角色 则可以选择角色
+        'type' => [
+            'name'      => '权益',
+            'type'      => 'varchar(100)',
+        ],
+
+        'score_id'        => [
+            'name'      => '佣金积分',
+            'type'      => 'int(11)',
+            'value'     => 'place_score/info',
+        ],
+
+        'percent' => [
+            'name'      => '佣金比例',
+            'type'      => 'decimal(11,1)',
+        ],
+
+        'sort' => [
+            'name'      => '排序',
+            'type'      => 'int(11)',
+            'default'   => 1,
+        ],
+        
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '开启',
+                2 => '禁用',
+            ],
+        ],
+    ],
+    'index' => [
+        'search' => 'type,level_id,percent',
+    ],
+];

+ 42 - 46
src/place/user/table/role.php → src/place/role/table/user.php

@@ -1,46 +1,42 @@
-<?php
-return array
-(
-    'name' => '用户角色关联表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-        'role_id'        => array
-        (
-            'name'      => '角色ID',
-            'type'      => 'int(11)',
-        ),
-
-        'level_id'        => array
-        (
-            'name'      => '角色等级ID',
-            'type'      => 'int(11)',
-        ),
-        
-        'edate'         => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '过期时间',
-        ),
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '正常',
-                2 => '失效',
-            ),
-        ),
-    ),
-    'index' => array
-    (
-        'search' => 'uid,role_id,level_id',
-    ),
-);
+<?php
+return [
+    'name' => '用户角色关联表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'uid'       => [
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ],
+        'info_id'        => [
+            'name'      => '角色ID',
+            'type'      => 'int(11)',
+        ],
+
+        'level_id'        => [
+            'name'      => '角色等级ID',
+            'type'      => 'int(11)',
+        ],
+
+        'card'        => [
+            'name'      => '卡号',
+            'type'      => 'varchar(32)',
+        ],
+        
+        'edate'         => [
+            'type'      => 'int(11)',
+            'name'      => '过期时间',
+        ],
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '正常',
+                2 => '失效',
+            ],
+        ],
+    ],
+    'index' => [
+        'search' => 'uid,info_id,level_id,card',
+    ],
+];

+ 10 - 10
src/place/score/lib/Action.php

@@ -2,19 +2,19 @@
 use Dever;
 class Action
 {
-    public function get($cate_name, $name)
+    public function get($cate, $name, $type)
     {
         $data['name'] = $name;
         $action = Dever::db('action', 'place_score')->find($data);
-        if (!$action) {
-            $cate_data['name'] = $cate_name;
-            $action_cate = Dever::db('action_cate', 'place_score')->find($cate_data);
-            if (!$action_cate) {
-                $data['cate_id'] = Dever::db('action_cate', 'place_score')->insert($cate_data);
-            }
-            $action = array();
-            $action['id'] = Dever::db('action', 'place_score')->insert($data);
+        if ($action) {
+            return $action['id'];
         }
-        return $action;
+        $cate_data['name'] = $cate;
+        $cate = Dever::db('action_cate', 'place_score')->find($cate_data);
+        if (!$cate) {
+            $data['cate_id'] = Dever::db('action_cate', 'place_score')->insert($cate_data);
+        }
+        $data['type'] = $type;
+        return Dever::db('action', 'place_score')->insert($data);
     }
 }

+ 53 - 0
src/place/score/lib/Info.php

@@ -0,0 +1,53 @@
+<?php namespace Place_score\Lib;
+use Dever;
+class Info
+{
+    # 获取积分信息
+    public function getInfo($id, $uid)
+    {
+        $info = Dever::db('info', 'place_score')->find(['id' => $id, 'status' => 1], ['col' => 'id,name,symbol,recharge,withdraw,exp']);
+        if (!$info) {
+            Dever::error('积分信息错误');
+        }
+        $info['user'] = Dever::db('user', 'place_score')->find(['uid' => $uid, 'info_id' => $info['id']]);
+        return $info;
+    }
+
+    # 货币转成积分
+    public function toScore($value, $exp)
+    {
+        $value = Dever::number($value / $exp);
+        return $value;
+    }
+
+    # 积分转成货币
+    public function toMoney($value, $exp)
+    {
+        $value = Dever::number($value * $exp);
+        return $value;
+    }
+
+    # 获取价格文字
+    public function getText($price, $score)
+    {
+        $symbol = $score['symbol'];
+        if ($score['symbol_location'] == 1) {
+            if (is_[$price]) {
+                foreach ($price as &$v) {
+                    $v = $symbol . $v;
+                }
+            } else {
+                $price = $symbol . $price;
+            }
+        } else {
+            if (is_[$price]) {
+                foreach ($price as &$v) {
+                    $v .= $symbol;
+                }
+            } else {
+                $price .= $symbol;
+            }
+        }
+        return $price;
+    }
+}

+ 150 - 163
src/place/score/lib/Log.php

@@ -1,164 +1,151 @@
-<?php namespace Place_score\Lib;
-use Dever;
-class Log
-{
-    /**
-     * 增加行为日志 Dever::load('log', 'place_score')->add(1, '订单', '下单', 100);
-     *
-     * @return mixed
-     */
-    public function add_commit(){}
-    public function add($uid, $cate_name, $name, $status = 1, $num = 0)
-    {
-        $action = Dever::load('action', 'place_score')->get($cate_name, $name);
-        if ($action && $action['id'] > 0) {
-            $insert = array();
-            $insert['uid'] = $uid;
-            $insert['action_id'] = $action['id'];
-            //$insert['ip'] = Dever::ip();
-            $action_log_id = Dever::db('action_log', 'place_score')->insert($insert);
-
-            if ($action_log_id) {
-                $rule = Dever::db('rule', 'place_score')->select(array('action_id' => $action['id']));
-                $name = $cate_name . $name;
-                if ($rule) {
-                    foreach ($rule as $k => $v) {
-                        if ($num > 0) {
-                            $v['num'] = $num;
-                        }
-                        $this->rule($uid, $v, $action_log_id, $name, $status);
-                    }
-                }
-            }
-        }
-    }
-
-    private function rule($uid, $rule, $action_log_id, $name, $status = 1)
-    {
-        if (isset($rule['upper']) && $rule['upper'] == 2 && $rule['upper_limit'] >= 1) {
-            $upper = $this->upper($uid, $rule);
-            if (!$upper) {
-                # 达到积分上限
-                return;
-            }
-        }
-        $log = $this->inc($uid, $rule, $action_log_id, $name, $status);
-
-        if (!$log['id']) {
-            return;
-        }
-
-        # 增加返利
-        if (isset($rule['rebate']) && $rule['rebate'] > 1) {
-            $this->rebate($uid, $rule, $log, $name);
-        }
-    }
-
-    # 设置上限限制
-    private function upper($uid, $rule)
-    {
-        # 有上限限制
-        $limit = $rule['upper_limit'];
-        # 获取用户最新一次积分变化日志
-
-        $where = array();
-        $where['uid'] = $uid;
-        $where['info_id'] = $rule['info_id'];
-        $where['action_id'] = $rule['action_id'];
-        $user_log = Dever::db('user_log', 'place_score')->find($where);
-        if ($user_log) {
-            if ($rule['upper_type'] == 1) {
-                # 按天
-                $where['cdate'] = array('>=', strtotime(date('Y-m-d 00:00:00')));
-            } elseif ($rule['upper_type'] == 2) {
-                # 按小时
-                $where['cdate'] = array('>=', time() - ($rule['upper_time'] * 3600));
-            } elseif ($rule['upper_type'] == 3) {
-                # 永久
-            } else {
-                return true;
-            }
-
-            $user_log_num = Dever::db($this->user_log)->count($where);
-            if ($user_log_num >= $rule['upper_limit']) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    # 增加积分
-    private function inc($uid, $rule, $action_log_id, $name, $status = 1, $user_log_id = false)
-    {
-        $where = array();
-        $where['uid'] = $uid;
-        $where['info_id'] = $rule['info_id'];
-        $user = Dever::db('user', 'place_score')->find($where);
-
-        if (!$user) {
-            $user = array();
-            $user['id'] = Dever::db('user', 'place_score')->insert($where);
-            $user['balance'] = 0;
-            $user['udate'] = 0;
-        }
-
-        $update = array();
-
-        $log = $where;
-        $log['user_id'] = $user['id'];
-        $log['action_id'] = $rule['action_id'];
-        $log['action_log_id'] = $action_log_id;
-        $log['num'] = $rule['num'];
-        if ($user_log_id) {
-            $log['user_log_id'] = $user_log_id;
-            $log['mode'] = 2;
-        }
-        if ($status == 2) {
-            $log['balance'] = $user['balance'];
-        } else {
-            $log['balance'] = $user['balance'] + $rule['num'];
-        }
-        $log['name'] = $name;
-        $log['status'] = $status;
-        $log['id'] = Dever::db('user_log', 'place_score')->insert($log);
-
-        if ($log['id'] && $status == 1) {
-            if ($rule['num'] > 0) {
-                $update['total'] = array('+', $rule['num']);
-            } elseif ($rule['num'] < 0) {
-                $update['used'] = array('-', $rule['num']);
-            }
-            $update['balance'] = array('total', '-', 'used');
-            $state = Dever::db('user', 'place_score')->update(array('id' => $user['id'], 'udate' => $user['udate']), $update);
-            if (!$state) {
-                Dever::error('请求失败请重试');
-            }
-        }
-
-        return $log;
-    }
-
-    # 返利
-    private function rebate($uid, $rule, $log, $name)
-    {
-        if (!strstr($rule['rebate_value'], ':')) {
-            $rule['rebate_value'] = '1:' . $rule['rebate_value'];
-        }
-        $temp = explode(',', $rule['rebate_value']);
-        $parent_uid = false;
-        $rule['info_id'] = $rule['rebate_info_id'];
-        $name = '用户[' . $uid . ']' . $name . '返利';
-        foreach ($temp as $k => $v) {
-            list($level, $value) = explode(':', $v);
-            if ($rule['rebate'] == 2) {
-                # 百分比
-                $value = round($rule['num']*($value/100), 2);
-            }
-            $parent_uid = Dever::load('relation', 'invite')->getParent($uid, $level);
-            if ($parent_uid && $parent_uid > 0) {
-                $rule['num'] = $value;
-                $this->inc($parent_uid, $rule, $log['action_log_id'], $name, 1, $log['id']);
-            }
-        }
-    }
+<?php namespace Place_score\Lib;
+use Dever;
+class Log
+{
+    public $action_id;
+    public $score_id;
+    public $uid;
+
+    /**
+     * 增加行为日志 Dever::load('log', 'place_score')->add(1, '订单', '下单', 100);
+     * 1是正常互动行为,11是购买资源
+     *  Dever::load('log', 'place_score')->action('订单', '下单', 11)->score($score_id)->add($this->order['uid'], 100);
+     * Dever::load('log', 'place_score')->action('互动', '收藏')->add($this->order['uid']);
+     * @return mixed
+     */
+    public function add_commit(){}
+    public function add($uid, $num = 0, $desc = '', $status = 1)
+    {
+        $this->uid = $uid;
+        $this->status = $status;
+        if (!$this->action_id) {
+            Dever::error('用户行为错误');
+        }
+        if ($this->score_id && $num != 0) {
+            # 积分操作
+            $this->inc($this->score_id, $num, $desc);
+        }
+
+        # 规则操作
+        $rule = Dever::db('rule', 'place_score')->select(['action_id' => $this->action_id]);
+        if ($rule) {
+            foreach ($rule as $k => $v) {
+                $this->rule($v);
+            }
+        }
+    }
+
+    public function action($cate, $name, $type = 1)
+    {
+        $this->action_id = Dever::load('action', 'place_score')->get($cate, $name, $type);
+        return $this;
+    }
+    public function score($score_id)
+    {
+        $this->score_id = $score_id;
+        return $this;
+    }
+
+    # 根据规则操作积分
+    private function rule($rule)
+    {
+        if (isset($rule['upper']) && $rule['upper'] == 2 && $rule['upper_limit'] >= 1) {
+            $upper = $this->upper($rule);
+            if (!$upper) {
+                # 达到积分上限
+                return;
+            }
+        }
+        $log = $this->inc($rule['info_id'], $rule['num']);
+
+        if (!$log['id']) {
+            return;
+        }
+
+        # 增加返利 暂时无效
+    }
+
+    # 设置上限限制
+    private function upper($rule)
+    {
+        # 有上限限制
+        $limit = $rule['upper_limit'];
+        # 获取用户最新一次积分变化日志
+
+        $where = [];
+        $where['uid'] = $this->uid;
+        $where['info_id'] = $rule['info_id'];
+        $where['action_id'] = $rule['action_id'];
+        $log = Dever::db('user_log', 'place_score')->find($where);
+        if ($log) {
+            if ($rule['upper_type'] == 1) {
+                # 按天
+                $where['cdate'] = ['>=', strtotime(date('Y-m-d 00:00:00'))];
+            } elseif ($rule['upper_type'] == 2) {
+                # 按小时
+                $where['cdate'] = ['>=', time() - ($rule['upper_time'] * 3600)];
+            } elseif ($rule['upper_type'] == 3) {
+                # 永久
+            } else {
+                return true;
+            }
+
+            $user_log_num = Dever::db('user_log', 'place_score')->count($where);
+            if ($user_log_num >= $rule['upper_limit']) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    # 增加积分
+    public function inc($info_id, $num, $desc = '')
+    {
+        # 获取账户信息
+        $where = [];
+        $where['uid'] = $this->uid;
+        $where['info_id'] = $info_id;
+        $user = Dever::db('user', 'place_score')->find($where);
+
+        if (!$user) {
+            $user = [];
+            $user['id'] = Dever::db('user', 'place_score')->insert($where);
+            $user['balance'] = 0;
+            $user['udate'] = 0;
+        }
+
+        $update = [];
+
+        $log = $where;
+        $log['user_id'] = $user['id'];
+        $log['action_id'] = $this->action_id;
+        $log['num'] = $num;
+        $log['status'] = $this->status;
+        if ($desc) {
+            $log['desc'] = $desc;
+        }
+
+        if ($log['status'] == 2) {
+            $log['balance'] = $user['balance'];
+        } else {
+            $log['balance'] = bcadd($user['balance'], $log['num'], 2);
+        }
+        $log['id'] = Dever::db('user_log', 'place_score')->insert($log);
+
+        if ($log['id'] && $this->status == 1) {
+            if ($log['num'] > 0) {
+                $update['total'] = ['+', $log['num']];
+            } elseif ($log['num'] < 0) {
+                $update['used'] = ['-', $log['num']];
+            }
+            $update['balance'] = ['total', '-', 'used'];
+            # 这里加上乐观锁,第三个参数就是,框架自动处理
+            $state = Dever::db('user', 'place_score')->update(['id' => $user['id'], 'udate' => $user['udate']], $update, true);
+            if (!$state) {
+                Dever::error('请求失败请重试');
+            }
+        }
+
+        return $log;
+    }
 }

+ 8 - 2
src/place/score/lib/Rebate.php

@@ -4,11 +4,17 @@ class Rebate
 {
     public function getInfo($type, $type_id)
     {
-        $html = array();
+        $html = [];
         $data = $this->get($type, $type_id);
         if ($data) {
             foreach ($data as $v) {
-                $html[] = $v['name'] . '('.$v['percent'].'%)';
+                $v['percent'] = explode(',', $v['percent']);
+                $percent = [];
+                foreach ($v['percent'] as $v1) {
+                    $percent[] = $v1 . '%';
+                }
+                $percent = implode('-', $percent);
+                $html[] = $v['name'] . '('.$percent.')';
             }
         }
         $html = implode('、', $html);

+ 25 - 0
src/place/score/lib/User.php

@@ -0,0 +1,25 @@
+<?php namespace Place_score\Lib;
+use Dever;
+class User
+{
+    # 获取账户信息
+    public function getInfo($uid, $score)
+    {
+        $result = [];
+        $result['name'] = $score['name'];
+        $result['yue'] = 0;
+        $user = Dever::db('user', 'place_score')->find(['uid' => $uid, 'info_id' => $score['id']]);
+        if ($user) {
+            $result['yue'] = Dever::number($user['balance']);
+        }
+        $result['yue_text'] = Dever::load('info', 'place_score')->getText($result['yue'], $score);
+        return $result;
+    }
+
+    # 获取账户列表
+    public function getList($uid)
+    {
+        $user = Dever::db('user', 'place_score')->kv(['uid' => $uid], ['kv' => ['info_id', 'balance']]);
+        return $user;
+    }
+}

+ 18 - 0
src/place/score/manage/Lib/Action.php

@@ -0,0 +1,18 @@
+<?php namespace Place_score\Manage\Lib;
+use Dever;
+class Action
+{
+    # 获取互动行为
+    public function getList()
+    {
+        $data = Dever::db('action', 'place_score')->select(['type' => 1]);
+        return $data;
+        if ($data) {
+            foreach ($data as &$v) {
+                $cate = Dever::db('action_cate', 'place_score')->find($v['cate_id']);
+                $v['name'] = $cate['name'] . '-' . $v['name'];
+            }
+        }
+        return $data;
+    }
+}

+ 22 - 28
src/place/score/manage/convert.php

@@ -1,28 +1,22 @@
-<?php
-return array
-(
-    'update' => array
-    (
-        'field'    => array
-        (
-            'convert_info_id' => array
-            (
-                'type' => 'select',
-                'tips' => '选择要转换的目标积分',
-            ),
-            'value' => array
-            (
-                'tips' => '直接输入要转换的数值,如输入100,就是当前积分100个可以转换1个目标积分',
-                'placeholder' => '输入转换数值',
-            ),
-            'status' => array
-            (
-                'width' => '40',
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'update' => [
+        'field'    => [
+            'convert_info_id' => [
+                'type' => 'select',
+                'tips' => '选择要转换的目标积分',
+            ],
+            'value' => [
+                'tips' => '直接输入要转换的数值,如输入100,就是当前积分100个可以转换1个目标积分',
+                'placeholder' => '输入转换数值',
+            ],
+            'status' => [
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+    ],
+];

+ 47 - 48
src/place/score/manage/core.php

@@ -1,48 +1,47 @@
-<?php
-return array
-(
-    'menu' => array
-    (
-        'set_score' => array
-        (
-            'parent'    => 'sector_place_set',
-            'name'      => '积分配置',
-            'icon'      => 'currency-fill',
-            'sort'      => '102',
-        ),
-
-        'info' => array
-        (
-            'parent'    => 'set_score',
-            'name'      => '积分管理',
-            'icon'      => 'currency-line',
-            'sort'      => '2',
-        ),
-
-        'rule' => array
-        (
-            'parent'    => 'set_score',
-            'name'      => '规则设置',
-            'icon'      => 'currency-line',
-            'sort'      => '100',
-            'show'      => 3,
-        ),
-
-        'user' => array
-        (
-            'parent'    => 'set_score',
-            'name'      => '用户积分',
-            'icon'      => 'honor-of-kings-line',
-            'sort'      => '1',
-        ),
-
-        'user_log' => array
-        (
-            'parent'    => 'set_score',
-            'name'      => '积分日志',
-            'icon'      => 'honor-of-kings-line',
-            'sort'      => '100',
-            'show'      => 3,
-        ),
-    ),
-);
+<?php
+return [
+    'menu' => [
+        'set_score' => [
+            'parent'    => 'sector_place_set',
+            'name'      => '积分配置',
+            'icon'      => 'currency-fill',
+            'sort'      => '102',
+        ],
+
+        'info' => [
+            'parent'    => 'set_score',
+            'name'      => '积分管理',
+            'icon'      => 'currency-line',
+            'sort'      => '2',
+        ],
+
+        'rule' => [
+            'parent'    => 'set_score',
+            'name'      => '规则设置',
+            'sort'      => '100',
+            'show'      => 3,
+        ],
+
+        'recharge' => [
+            'parent'    => 'set_score',
+            'name'      => '充值设置',
+            'sort'      => '100',
+            'show'      => 3,
+        ],
+
+        'user' => [
+            'parent'    => 'set_score',
+            'name'      => '用户积分',
+            'icon'      => 'honor-of-kings-line',
+            'sort'      => '1',
+        ],
+
+        'user_log' => [
+            'parent'    => 'set_score',
+            'name'      => '积分日志',
+            'icon'      => 'honor-of-kings-line',
+            'sort'      => '100',
+            'show'      => 3,
+        ],
+    ],
+];

+ 84 - 78
src/place/score/manage/info.php

@@ -1,78 +1,84 @@
-<?php
-return array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'name',
-            'exp',
-            'symbol',
-            'symbol_location',
-            'sort' => array
-            (
-                'type' => 'input',
-                'tips' => '双击修改,正序排序',
-            ),
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-        'button' => array
-        (
-            '新增' => array('fastadd'),
-        ),
-        'data_button' => array
-        (
-            '编辑'  => array('fastedit'),
-            '规则设置' => array('route', array
-            (
-                'path' => 'set_score/rule',
-                'param' => array
-                (
-                    'set' => array('info_id' => 'id', 'menu' => 'set_score/info', 'parent' => 'set_score/info'),
-                ),
-            )),
-        ),
-        'search'    => array
-        (
-            'name',
-        ),
-    ),
-    'update' => array
-    (
-        'field'    => array
-        (
-            'name' => array
-            (
-                'rules' => true,
-            ),
-            'exp' => array
-            (
-                'rules' => true,
-                'tips' => '当前积分与支付货币之间的换算关系,填写100,则100积分等于1支付货币<br />当使用该积分进行支付时,将根据换算关系自动转换成支付货币,用以拉起支付<br />填写0,无法与支付货币自动换算',
-            ),
-            'symbol' => array
-            (
-                'tips' => '将展示在待支付的价格里',
-                'rules' => true,
-            ),
-            'symbol_location' => array
-            (
-                'tips' => '展示在待支付的价格前面还是后面',
-                'rules' => true,
-                'type' => 'radio',
-            ),
-            'place_score/convert' => array
-            (
-                'tips' => '设置可以转换成的目标积分,设置之后,可以在积分管理中进行转换',
-                'name' => '转换设置',
-                'where'  => array('info_id' => 'id'),
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'list' => [
+        'field'      => [
+            'name',
+            'exp',
+            'symbol',
+            'recharge',
+            'withdraw',
+            'sort' => [
+                'type' => 'input',
+                'tips' => '双击修改,正序排序',
+            ],
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'button' => [
+            '新增' => ['fastadd'],
+        ],
+        'data_button' => [
+            '编辑'  => ['fastedit'],
+            '规则设置' => ['route', [
+                'path' => 'set_score/rule',
+                'param' => [
+                    'set' => ['info_id' => 'id', 'menu' => 'set_score/info', 'parent' => 'set_score/info'],
+                ],
+            ]],
+            '充值设置' => ['route', [
+                'path' => 'set_score/recharge',
+                'param' => [
+                    'set' => ['info_id' => 'id', 'menu' => 'set_score/info', 'parent' => 'set_score/info'],
+                ],
+            ], '','recharge=1'],
+        ],
+        'search'    => [
+            'name',
+        ],
+    ],
+    'update' => [
+        'control' => [
+            'withdraw_fee' => 'withdraw=1',
+        ],
+        'field'    => [
+            'name' => [
+                'rules' => true,
+            ],
+            'exp' => [
+                'rules' => true,
+                'tips' => '当前积分与支付货币之间的换算关系,填写100,则100积分等于1支付货币<br />当使用该积分进行支付时,将根据换算关系自动转换成支付货币,用以拉起支付<br />填写0,无法与支付货币自动换算,支付和提现都将无法使用',
+            ],
+            'symbol' => [
+                'tips' => '将展示在待支付的价格里',
+                'rules' => true,
+            ],
+            'symbol_location' => [
+                'tips' => '展示在待支付的价格前面还是后面',
+                'rules' => true,
+                'type' => 'radio',
+            ],
+            'recharge' => [
+                'tips' => '开启后,根据货币换算规则,用户可以充值任意金额到该积分账户上',
+                'rules' => true,
+                'type' => 'radio',
+            ],
+            'withdraw' => [
+                'tips' => '开启后,根据货币换算规则,用户可以将积分提现到微信账户、支付宝账户、银行卡上',
+                'rules' => true,
+                'type' => 'radio',
+            ],
+            'withdraw_fee' => [
+                'tips' => '提现将扣除用户当前积分百分比手续费,如设置5,提现100,则实际到账95',
+            ],
+            'place_score/convert' => [
+                'tips' => '设置可以转换成的目标积分,设置之后,用户可以将该积分转成目标积分',
+                'name' => '转换设置',
+                'where'  => ['info_id' => 'id'],
+            ],
+        ],
+    ],
+];

+ 23 - 29
src/place/score/manage/rebate.php

@@ -1,29 +1,23 @@
-<?php
-return array
-(
-    'update' => array
-    (
-        'field'    => array
-        (
-            'info_id' => array
-            (
-                'type' => 'select',
-                'tips' => '选择购买当前项目,返利的积分',
-            ),
-            'percent' => array
-            (
-                'tips' => '支持多层级返利,半角逗号隔开<br />第一个为当前用户<br />第二个为当前用户上级<br />第三个为当前用户上上级,以此类推<br />如输入:0,1,2,就是给当前用户返利0%,上级返1%,上上级返2%<br /><span style="color:red">注意:本功能仅返积分,目前仅支持三层返利,请勿违反法律法规</span>',
-                'placeholder' => '输入返利比例数值',
-            ),
-            /*
-            'status' => array
-            (
-                'width' => '40',
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),*/
-        ),
-    ),
-);
+<?php
+return [
+    'update' => [
+        'field'    => [
+            'info_id' => [
+                'type' => 'select',
+                'tips' => '选择购买当前项目,返利的积分',
+            ],
+            'percent' => [
+                'tips' => '支持多层级返利,半角逗号隔开<br />第一个为当前用户<br />第二个为当前用户上级<br />第三个为当前用户上上级,以此类推<br />如输入:0,1,2,就是给当前用户返利0%,上级返1%,上上级返2%<br /><span style="color:red">注意:本功能仅返积分,目前仅支持三层返利,请勿违反法律法规</span>',
+                'placeholder' => '输入返利比例数值',
+            ],
+            /*
+            'status' => [
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],*/
+        ],
+    ],
+];

+ 45 - 0
src/place/score/manage/recharge.php

@@ -0,0 +1,45 @@
+<?php
+$info_id = Dever::input(['set', 'field'])['info_id'] ?? 0;
+return [
+    'list' => [
+        'where' => ['info_id' => $info_id],
+        'field'      => [
+            'name',
+            'value',
+            'price',
+            'sort' => [
+                'type' => 'input',
+                'tips' => '双击修改,正序排序',
+            ],
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'button' => [
+            '新增' => ['fastadd', ['info_id' => $info_id]],
+        ],
+        'data_button' => [
+            '编辑'  => ['fastedit'],
+        ],
+        'search'    => [
+            'name',
+        ],
+    ],
+    'update' => [
+        'field'    => [
+            'info_id',
+            'name' => [
+                'rules' => true,
+            ],
+            'value' => [
+                'rules' => true,
+            ],
+            'price' => [
+                'rules' => true,
+            ],
+        ],
+    ],
+];

+ 71 - 90
src/place/score/manage/rule.php

@@ -1,90 +1,71 @@
-<?php
-$info_id = Dever::input(['set', 'field'])['info_id'] ?? 0;
-return array
-(
-    'list' => array
-    (
-        'where' => array('info_id' => $info_id),
-        'field'      => array
-        (
-            'action_id',
-            'num',
-            'upper',
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-        'button' => array
-        (
-            '新增' => array('fastadd', array('info_id' => $info_id)),
-        ),
-        'data_button' => array
-        (
-            '编辑'  => array('fastedit'),
-        ),
-        'search'    => array
-        (
-            'action_id',
-        ),
-    ),
-    'update' => array
-    (
-        'control' => array
-        (
-            'upper_type' => array
-            (
-                'upper' => 2,
-            ),
-            'upper_time' => array
-            (
-                'upper' => 2,
-                'upper_type' => 2,
-            ),
-            'upper_limit' => array
-            (
-                'upper' => 2,
-            ),
-        ),
-        'field'    => array
-        (
-            'info_id',
-            'action_id' => array
-            (
-                'rules' => true,
-            ),
-            'num' => array
-            (
-                'rules' => true,
-            ),
-            'upper' => array
-            (
-                'rules' => true,
-                'type' => 'radio',
-            ),
-            'upper_type' => array
-            (
-                'rules' => true,
-                'type' => 'radio',
-            ),
-            'upper_time' => array
-            (
-                'rules' => true,
-            ),
-            'upper_limit' => array
-            (
-                'rules' => true,
-                'tips' => '按照所选的限制类型设置限制次数<br />如限制类型为按8小时,限制次数填写2,则该积分规则每8个小时仅能生效2次',
-            ),
-            'place_score/rebate' => array
-            (
-                'name' => '返利积分',
-                'tips' => '选择返利积分后,当用户获得积分后,将按照规则返利',
-                'where'  => array('type' => 5,'type_id' => 'id'),
-            ),
-        ),
-    ),
-);
+<?php
+$info_id = Dever::input(['set', 'field'])['info_id'] ?? 0;
+return [
+    'list' => [
+        'where' => ['info_id' => $info_id],
+        'field'      => [
+            'action_id',
+            'num',
+            'upper',
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'button' => [
+            '新增' => ['fastadd', ['info_id' => $info_id]],
+        ],
+        'data_button' => [
+            '编辑'  => ['fastedit'],
+        ],
+        'search'    => [
+            'action_id',
+        ],
+    ],
+    'update' => [
+        'control' => [
+            'upper_type' => [
+                'upper' => 2,
+            ],
+            'upper_time' => [
+                'upper' => 2,
+                'upper_type' => 2,
+            ],
+            'upper_limit' => [
+                'upper' => 2,
+            ],
+        ],
+        'field'    => [
+            'info_id',
+            'action_id' => [
+                'rules' => true,
+            ],
+            'num' => [
+                'rules' => true,
+            ],
+            'upper' => [
+                'rules' => true,
+                'type' => 'radio',
+            ],
+            'upper_type' => [
+                'rules' => true,
+                'type' => 'radio',
+            ],
+            'upper_time' => [
+                'rules' => true,
+            ],
+            'upper_limit' => [
+                'rules' => true,
+                'tips' => '按照所选的限制类型设置限制次数<br />如限制类型为按8小时,限制次数填写2,则该积分规则每8个小时仅能生效2次',
+            ],
+            /*
+            'place_score/rebate' => [
+                'name' => '返利积分',
+                'tips' => '选择返利积分后,当用户获得积分后,将按照规则返利',
+                'where'  => ['type' => 5,'type_id' => 'id'],
+            ],*/
+        ],
+    ],
+];

+ 36 - 46
src/place/score/manage/user.php

@@ -1,46 +1,36 @@
-<?php
-return array
-(
-    'list' => array
-    (
-        'field'      => array
-        (
-            'uid' => array
-            (
-                'name' => '用户信息',
-                'show' => 'Dever::call("place_user/manage/user.getInfo", {uid})',
-            ),
-            'info_id',
-            'total',
-            'used',
-            'balance',
-            'status' => array
-            (
-                'type' => 'switch',
-                'show'  => '{status}',
-                'active_value' => 1,
-                'inactive_value' => 2,
-            ),
-        ),
-        'button' => array
-        (
-            //'新增' => array('fastadd'),
-        ),
-        'data_button' => array
-        (
-            '积分日志' => array('route', array
-            (
-                'path' => 'set_score/user_log',
-                'param' => array
-                (
-                    'set' => array('user_id' => 'id', 'menu' => 'set_score/user', 'parent' => 'set_score/user'),
-                ),
-            )),
-        ),
-        'search'    => array
-        (
-            'uid' => 'input',
-            'info_id',
-        ),
-    ),
-);
+<?php
+return [
+    'list' => [
+        'field'      => [
+            'uid' => [
+                'name' => '用户信息',
+                'show' => 'Dever::call("place_user/manage/user.getInfo", {uid})',
+            ],
+            'info_id',
+            'total',
+            'used',
+            'balance',
+            'status' => [
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ],
+        ],
+        'button' => [
+            //'新增' => ['fastadd'],
+        ],
+        'data_button' => [
+            '积分日志' => ['route', [
+                'path' => 'set_score/user_log',
+                'param' => [
+                    'set' => ['user_id' => 'id', 'menu' => 'set_score/user', 'parent' => 'set_score/user'],
+                ],
+            ]],
+        ],
+        'search'    => [
+            'uid' => 'input',
+            'info_id',
+        ],
+    ],
+];

+ 28 - 33
src/place/score/manage/user_log.php

@@ -1,33 +1,28 @@
-<?php
-$user_id = Dever::input(['set', 'field'])['user_id'] ?? 0;
-return array
-(
-    'list' => array
-    (
-        'where' => array('user_id' => $user_id),
-        'field'      => array
-        (
-            'info_id',
-            'action_id',
-            'mode',
-            'name',
-            'num',
-            'balance',
-            'status',
-            'cdate',
-        ),
-        'button' => array
-        (
-            
-        ),
-        'data_button' => array
-        (
-            
-        ),
-        'search'    => array
-        (
-            'action_id',
-            'status',
-        ),
-    ),
-);
+<?php
+$user_id = Dever::input(['set', 'field'])['user_id'] ?? 0;
+return [
+    'list' => [
+        'where' => ['user_id' => $user_id],
+        'field'      => [
+            'info_id',
+            'action_id',
+            'num',
+            'balance',
+            'status',
+            'cdate',
+            'desc' => [
+                'show' => '"{desc}" ? "{desc}" : "-"'
+            ],
+        ],
+        'button' => [
+            
+        ],
+        'data_button' => [
+            
+        ],
+        'search'    => [
+            'action_id',
+            'status',
+        ],
+    ],
+];

+ 20 - 12
src/place/score/table/action.php

@@ -1,19 +1,27 @@
 <?php
-return array
-(
+return [
     'name' => '用户行为配置表',
-    'struct' => array
-    (
-        'name' => array
-        (
+    'struct' => [
+        'name' => [
             'name'      => '行为名称',
             'type'      => 'varchar(80)',
-        ),
-        'cate_id'       => array
-        (
+        ],
+        'cate_id'       => [
             'type'      => 'int(11)',
             'name'      => '行为分类',
             'value'     => 'score/action_cate',
-        ),
-    ),
-);
+        ],
+        'type' => [
+            'name'      => '行为类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '互动行为',
+                11 => '购买资源',
+                12 => '购买角色',
+                13 => '积分充值',
+                14 => '积分提现',
+            ]
+        ]
+    ]
+];

+ 10 - 13
src/place/score/table/action_cate.php

@@ -1,13 +1,10 @@
-<?php
-return array
-(
-    'name' => '用户行为分类表',
-    'struct' => array
-    (
-        'name' => array
-        (
-            'name'      => '分类名称',
-            'type'      => 'varchar(80)',
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '用户行为分类表',
+    'struct' => [
+        'name' => [
+            'name'      => '分类名称',
+            'type'      => 'varchar(80)',
+        ],
+    ],
+];

+ 0 - 32
src/place/score/table/action_log.php

@@ -1,32 +0,0 @@
-<?php
-return array
-(
-    'name' => '用户行为日志表',
-    'partition' => 'Dever::call("manage/common.system")',
-    //'store' => 'log',
-    'struct' => array
-    (
-        'uid'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '用户',
-        ),
-        'action_id'       => array
-        (
-            'type'      => 'int(11)',
-            'name'      => '所属行为',
-        ),
-        /*
-        'ip'       => array
-        (
-            'type'      => 'varchar(32)',
-            'name'      => 'IP地址',
-        ),
-        */
-    ),
-
-    'index' => array
-    (
-        'search' => 'uid,action_id',
-    ),
-);

+ 34 - 41
src/place/score/table/convert.php

@@ -1,41 +1,34 @@
-<?php
-return array
-(
-    'name' => '用户积分转换规则表',
-    'partition' => 'Dever::call("manage/common.system")',
-    'struct' => array
-    (
-        'info_id'        => array
-        (
-            'name'      => '转换积分',
-            'type'      => 'int(11)',
-            'value'     => 'place_score/info',
-        ),
-
-        'convert_info_id'        => array
-        (
-            'name'      => '目标积分',
-            'type'      => 'int(11)',
-            'value'     => 'place_score/info',
-        ),
-
-        'value' => array
-        (
-            'name'      => '转换数值',
-            'type'      => 'varchar(50)',
-            'default'   => '1',
-        ),
-
-        'status' => array
-        (
-            'name'      => '状态',
-            'type'      => 'tinyint(1)',
-            'default'   => 1,
-            'value'     => array
-            (
-                1 => '正常',
-                2 => '封禁',
-            ),
-        ),
-    ),
-);
+<?php
+return [
+    'name' => '用户积分转换规则表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => [
+        'info_id'        => [
+            'name'      => '转换积分',
+            'type'      => 'int(11)',
+            'value'     => 'place_score/info',
+        ],
+
+        'convert_info_id'        => [
+            'name'      => '目标积分',
+            'type'      => 'int(11)',
+            'value'     => 'place_score/info',
+        ],
+
+        'value' => [
+            'name'      => '转换数值',
+            'type'      => 'varchar(50)',
+            'default'   => '1',
+        ],
+
+        'status' => [
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => [
+                1 => '正常',
+                2 => '封禁',
+            ],
+        ],
+    ],
+];

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