正在显示
28 个修改的文件
包含
687 行增加
和
100 行删除
@@ -425,4 +425,94 @@ class CategoriesController extends BaseController | @@ -425,4 +425,94 @@ class CategoriesController extends BaseController | ||
425 | ); | 425 | ); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | + | ||
429 | +// /** | ||
430 | +// * 获取 实例 | ||
431 | +// * | ||
432 | +// * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|JsonResponse | ||
433 | +// */ | ||
434 | +// public function labels($id) | ||
435 | +// { | ||
436 | +// $list = null; | ||
437 | +// try { | ||
438 | +// // 获取数据,如果没有获取到抛出异常 | ||
439 | +// $model = $this->model->findOrFail($id); | ||
440 | +// | ||
441 | +// $list = $model->labels()->get(); | ||
442 | +// return view('admin::category.labels', compact('id', 'list')) ; | ||
443 | +// | ||
444 | +// } catch (ModelNotFoundException $e) { | ||
445 | +// return view('admin::category.labels', compact('id', 'list')) ; | ||
446 | +// } | ||
447 | +// } | ||
448 | + | ||
449 | + /** | ||
450 | + * 添加 标签 界面 | ||
451 | + * | ||
452 | + * @param $id | ||
453 | + */ | ||
454 | + public function childPage($id) | ||
455 | + { | ||
456 | + $label_id = request('id', 0); | ||
457 | + $label = null; | ||
458 | + if ($label_id) { | ||
459 | + $label = CategoryLabel::find($label_id); | ||
460 | + } | ||
461 | + // 获取数据,如果没有获取到抛出异常 | ||
462 | + return view('admin::category.child', compact('id', 'label_id','label')) ; | ||
463 | + } | ||
464 | + | ||
465 | + /** | ||
466 | + * 添加 标签 | ||
467 | + * | ||
468 | + * @param integer $id 主键id | ||
469 | + * | ||
470 | + * @return JsonResponse | ||
471 | + */ | ||
472 | + public function addChild($id) | ||
473 | + { | ||
474 | + try { | ||
475 | + $label_id = request('label_id', 0); | ||
476 | + if ($label_id > 0) { | ||
477 | + // 获取数据,如果没有获取到抛出异常 | ||
478 | + $model = CategoryLabel::findOrFail($label_id); | ||
479 | + $model->name = request('name'); | ||
480 | + $model->can_multiple = request('can_multiple', 0); | ||
481 | + $model->semantics = request('semantics'); | ||
482 | + $model->description = request('description'); | ||
483 | + $model->save(); | ||
484 | + | ||
485 | + } else { | ||
486 | + // 获取数据,如果没有获取到抛出异常 | ||
487 | + $model = $this->model->findOrFail($id); | ||
488 | + $result = $model->labels()->create([ | ||
489 | + 'name' => request('name'), | ||
490 | + 'semantics' => request('semantics'), | ||
491 | + 'description' => request('description'), | ||
492 | + 'can_multiple' => request('can_multiple', 0), | ||
493 | + ]); | ||
494 | + | ||
495 | + // 同步到远程服务器 | ||
496 | +// CategoryLabelCreatedJob::dispatch($result); | ||
497 | + | ||
498 | + } | ||
499 | + | ||
500 | + return response()->json( | ||
501 | + [ | ||
502 | + 'code' => 0, | ||
503 | + 'status' => 1, | ||
504 | + 'message' => __('operate_succeeded'), | ||
505 | + ] | ||
506 | + ); | ||
507 | + } catch (\Exception $e) { | ||
508 | + return response()->json( | ||
509 | + [ | ||
510 | + 'code' => 1, | ||
511 | + 'status' => 0, | ||
512 | + 'message' => $e->getMessage(), | ||
513 | + ] | ||
514 | + ); | ||
515 | + } | ||
516 | + } | ||
517 | + | ||
428 | } | 518 | } |
@@ -107,7 +107,7 @@ class WithdrawalsController extends BaseController | @@ -107,7 +107,7 @@ class WithdrawalsController extends BaseController | ||
107 | 'amount' => $amount, | 107 | 'amount' => $amount, |
108 | 'type' => WalletRecord::DECREASE, | 108 | 'type' => WalletRecord::DECREASE, |
109 | 'event' => WalletRecord::WITHDRAW, | 109 | 'event' => WalletRecord::WITHDRAW, |
110 | -// 'ratio' => TODO | 110 | + 'ratio' => $model->ratio, |
111 | ]; | 111 | ]; |
112 | $r = $model->records()->create($record); | 112 | $r = $model->records()->create($record); |
113 | if (!$r) { | 113 | if (!$r) { |
@@ -927,4 +927,31 @@ SCRIPT; | @@ -927,4 +927,31 @@ SCRIPT; | ||
927 | <a href="javascript:;" data-id="{$id}" class="btn btn-sm btn-success grid-add-times" >{$action}</a> | 927 | <a href="javascript:;" data-id="{$id}" class="btn btn-sm btn-success grid-add-times" >{$action}</a> |
928 | EOT; | 928 | EOT; |
929 | } | 929 | } |
930 | + | ||
931 | + /** | ||
932 | + * 渲染 添加标签 | ||
933 | + * | ||
934 | + * @param integer $id | ||
935 | + * @param $url | ||
936 | + * @return string | ||
937 | + */ | ||
938 | + public static function renderChildCategory($id, $url) | ||
939 | + { | ||
940 | + $action = '<i class="fa fa-check-square-o"></i> ' .__('添加子分类'); | ||
941 | + | ||
942 | + $script = <<<SCRIPT | ||
943 | +$('.grid-add-label').unbind('click').click(function() { | ||
944 | + var id = $(this).data('id'); | ||
945 | + var url= '{$url}/' + id +'/child'; | ||
946 | + layer_iframe( url,'$action',2,0.5,['80%','60%'] ); | ||
947 | +}); | ||
948 | + | ||
949 | +SCRIPT; | ||
950 | + | ||
951 | + Admin::script($script); | ||
952 | + | ||
953 | + return <<<EOT | ||
954 | +<a href="javascript:;" data-id="{$id}" class="btn btn-sm btn-success grid-add-label" style="display:block;width:120px">{$action}</a> | ||
955 | +EOT; | ||
956 | + } | ||
930 | } | 957 | } |
@@ -39,14 +39,26 @@ trait CategoryForm | @@ -39,14 +39,26 @@ trait CategoryForm | ||
39 | { | 39 | { |
40 | // $this->formDisplayField('id', __('ID')); | 40 | // $this->formDisplayField('id', __('ID')); |
41 | $this->formTextField('name', '', 20, 1); | 41 | $this->formTextField('name', '', 20, 1); |
42 | - $this->formNumberField('consume_times'); | ||
43 | - $this->formRadioField('context', '', ChatRecord::CONTEXT_OPTIONS); | 42 | + |
43 | + $this->formSingleSelectField('pid', '一级分类', Category::getParents('store')) | ||
44 | + ->when('>=', 1, function () { | ||
45 | + $this->formNumberField('consume_times') | ||
46 | + ->setGroupClass('col-sm-12')->setWidth(8, 2) | ||
47 | + ; | ||
48 | + $this->formRadioField('context', '', ChatRecord::CONTEXT_OPTIONS) | ||
49 | + ->setGroupClass('col-sm-12')->setWidth(8, 2) | ||
50 | + ; | ||
51 | + $this->formTextAreaField('start_statement', '', 0, 5) | ||
52 | + ->setGroupClass('col-sm-12')->setWidth(8, 2) | ||
53 | + ; | ||
54 | + | ||
55 | + }); | ||
44 | $required = 1; | 56 | $required = 1; |
45 | if ($id > 0) { | 57 | if ($id > 0) { |
46 | $required = 0; | 58 | $required = 0; |
47 | } | 59 | } |
48 | $this->formSingleImageField('icon', '图标', $required); | 60 | $this->formSingleImageField('icon', '图标', $required); |
49 | - $this->formTextAreaField('start_statement', '', 0, 5); | 61 | + |
50 | $this->formTextAreaField('body', '内容', 0, 5); | 62 | $this->formTextAreaField('body', '内容', 0, 5); |
51 | // $this->formTextAreaField('description', '', 255, 3); | 63 | // $this->formTextAreaField('description', '', 255, 3); |
52 | $this->formCommonFields(1, 0, 1, 1); | 64 | $this->formCommonFields(1, 0, 1, 1); |
@@ -18,7 +18,10 @@ namespace App\Admin\Grids; | @@ -18,7 +18,10 @@ namespace App\Admin\Grids; | ||
18 | 18 | ||
19 | use App\Admin\Extensions\CustomActions; | 19 | use App\Admin\Extensions\CustomActions; |
20 | use App\Admin\Grids\Modal\CategoryExampleModal; | 20 | use App\Admin\Grids\Modal\CategoryExampleModal; |
21 | +use App\Models\Category\Category; | ||
21 | use Encore\Admin\Grid; | 22 | use Encore\Admin\Grid; |
23 | +use Encore\Admin\Widgets\Table; | ||
24 | +use function Clue\StreamFilter\fun; | ||
22 | 25 | ||
23 | /** | 26 | /** |
24 | * Class CategoryGrid. | 27 | * Class CategoryGrid. |
@@ -48,7 +51,7 @@ trait CategoryGrid | @@ -48,7 +51,7 @@ trait CategoryGrid | ||
48 | // 执行父类方法,设置默认的查询条件 | 51 | // 执行父类方法,设置默认的查询条件 |
49 | parent::setGridQuery(); | 52 | parent::setGridQuery(); |
50 | 53 | ||
51 | - $this->grid->model()->withCount(['labels','examples']); | 54 | + $this->grid->model()->with(['parent', 'children'])->withCount(['labels','examples', 'children']); |
52 | } | 55 | } |
53 | 56 | ||
54 | /** | 57 | /** |
@@ -64,9 +67,13 @@ trait CategoryGrid | @@ -64,9 +67,13 @@ trait CategoryGrid | ||
64 | $id = $actions->getKey(); | 67 | $id = $actions->getKey(); |
65 | // 当前的url | 68 | // 当前的url |
66 | $url = $actions->getResource(); | 69 | $url = $actions->getResource(); |
70 | + if (!$actions->row->pid) { | ||
71 | +// $actions->append(CustomActions::renderChildCategory($id, $url)); | ||
72 | + } else { | ||
67 | $actions->append(CustomActions::renderAddExample($id, $url)); | 73 | $actions->append(CustomActions::renderAddExample($id, $url)); |
68 | $actions->append(CustomActions::renderAddLabel($id, $url)); | 74 | $actions->append(CustomActions::renderAddLabel($id, $url)); |
69 | } | 75 | } |
76 | + } | ||
70 | 77 | ||
71 | /** | 78 | /** |
72 | * 为grid增加筛选条件 | 79 | * 为grid增加筛选条件 |
@@ -80,6 +87,7 @@ trait CategoryGrid | @@ -80,6 +87,7 @@ trait CategoryGrid | ||
80 | // 筛选条件默认展开 | 87 | // 筛选条件默认展开 |
81 | $filter->expand(); | 88 | $filter->expand(); |
82 | $this->filterText($filter, 'name'); | 89 | $this->filterText($filter, 'name'); |
90 | + $this->filterSingleSelect($filter, 'pid', '一级分类', Category::getParents()); | ||
83 | //去掉默认的搜索 | 91 | //去掉默认的搜索 |
84 | $filter->disableIdFilter(); | 92 | $filter->disableIdFilter(); |
85 | } | 93 | } |
@@ -97,12 +105,37 @@ trait CategoryGrid | @@ -97,12 +105,37 @@ trait CategoryGrid | ||
97 | { | 105 | { |
98 | $this->gridRowNo(); | 106 | $this->gridRowNo(); |
99 | $this->gridSingleImageField('icon'); | 107 | $this->gridSingleImageField('icon'); |
108 | + $this->gridTextField('parent.name', '上级分类'); | ||
100 | $this->gridTextField('name'); | 109 | $this->gridTextField('name'); |
101 | - $this->gridTextField('start_statement')->limit(100); | ||
102 | - $this->gridBoolField('context'); | ||
103 | - $this->gridTextField('consume_times'); | 110 | + $this->gridTextField('start_statement')->display(function ($value) { |
111 | + if ($this->pid == 0) { | ||
112 | + return '--'; | ||
113 | + } | ||
114 | + return $value; | ||
115 | + }); | ||
116 | +// $this->gridBoolField('context'); | ||
117 | + $this->gridTextField('context')->display(function ($value) { | ||
118 | + if ($this->pid == 0) { | ||
119 | + return '--'; | ||
120 | + } | ||
121 | + | ||
122 | + if ($value == 1) { | ||
123 | + return '<i class="fa fa-check text-green"></i>'; | ||
124 | + } | ||
125 | + | ||
126 | + return '<i class="fa fa-close text-red"></i>'; | ||
127 | + }); | ||
128 | + $this->gridTextField('consume_times')->display(function ($value) { | ||
129 | + if ($this->pid == 0) { | ||
130 | + return '--'; | ||
131 | + } | ||
132 | + return $value; | ||
133 | + }); | ||
104 | // $this->gridTextField('body')->limit(100); | 134 | // $this->gridTextField('body')->limit(100); |
105 | $this->gridNumberField('labels_count', '标签')->display(function ($value) { | 135 | $this->gridNumberField('labels_count', '标签')->display(function ($value) { |
136 | + if ($this->pid == 0) { | ||
137 | + return '--'; | ||
138 | + } | ||
106 | $id = $this->id; | 139 | $id = $this->id; |
107 | $url= "/admin/categories/$id/labels"; | 140 | $url= "/admin/categories/$id/labels"; |
108 | return "<a href='#' onclick=layer_iframe('$url','标签列表',2,0.5,['80%','80%'])>$value</a>"; | 141 | return "<a href='#' onclick=layer_iframe('$url','标签列表',2,0.5,['80%','80%'])>$value</a>"; |
@@ -110,10 +143,21 @@ trait CategoryGrid | @@ -110,10 +143,21 @@ trait CategoryGrid | ||
110 | 143 | ||
111 | // $this->gridNumberField('examples_count', __('实例展示'))->modal(__('实例展示'), CategoryExampleModal::class); | 144 | // $this->gridNumberField('examples_count', __('实例展示'))->modal(__('实例展示'), CategoryExampleModal::class); |
112 | $this->gridNumberField('examples_count', '实例展示')->display(function ($value) { | 145 | $this->gridNumberField('examples_count', '实例展示')->display(function ($value) { |
146 | + if ($this->pid == 0) { | ||
147 | + return '--'; | ||
148 | + } | ||
113 | $id = $this->id; | 149 | $id = $this->id; |
114 | $url= "/admin/categories/$id/examples"; | 150 | $url= "/admin/categories/$id/examples"; |
115 | return "<a href='#' onclick=layer_iframe('$url','实例展示',2,0.5,['80%','80%'])>$value</a>"; | 151 | return "<a href='#' onclick=layer_iframe('$url','实例展示',2,0.5,['80%','80%'])>$value</a>"; |
116 | }); | 152 | }); |
153 | + | ||
154 | +// $this->grid->column('children_count', '子分类')->expand(function ($model) { | ||
155 | +// $comments = $model->children->map(function ($comment) { | ||
156 | +// return $comment->only(['id', 'name', 'created_at']); | ||
157 | +// }); | ||
158 | +// | ||
159 | +// return new Table(['ID', '内容', '发布时间'], $comments->toArray()); | ||
160 | +// }); | ||
117 | $this->gridCommonFields(1, 0, 1, 1); | 161 | $this->gridCommonFields(1, 0, 1, 1); |
118 | } | 162 | } |
119 | 163 |
@@ -19,6 +19,7 @@ namespace App\Admin\Grids; | @@ -19,6 +19,7 @@ namespace App\Admin\Grids; | ||
19 | use App\Admin\Extensions\Actions\Audit; | 19 | use App\Admin\Extensions\Actions\Audit; |
20 | use App\Admin\Extensions\CustomActions; | 20 | use App\Admin\Extensions\CustomActions; |
21 | use App\Models\User\WithdrawRecord; | 21 | use App\Models\User\WithdrawRecord; |
22 | +use function Clue\StreamFilter\fun; | ||
22 | 23 | ||
23 | /** | 24 | /** |
24 | * Class WithdrawRecordGrid. | 25 | * Class WithdrawRecordGrid. |
@@ -107,7 +108,11 @@ trait WithdrawRecordGrid | @@ -107,7 +108,11 @@ trait WithdrawRecordGrid | ||
107 | $this->gridTextField('cardholder'); | 108 | $this->gridTextField('cardholder'); |
108 | $this->gridSingleImageField('receipt_code'); | 109 | $this->gridSingleImageField('receipt_code'); |
109 | $this->gridTextField('account'); | 110 | $this->gridTextField('account'); |
110 | - $this->gridNumberField('amount', '提现金额'); | 111 | + $this->gridCurrencyField('amount', '提现金额'); |
112 | + $this->gridCurrencyField('actual_amount', '实际到账金额'); | ||
113 | + $this->gridTextField('ratio', '费率')->display(function ($value) { | ||
114 | + return $value . '%'; | ||
115 | + }); | ||
111 | $this->gridSingleSelect('status', '提现状态', WithdrawRecord::STATUS_OPTIONS, WithdrawRecord::STATUS_COLOR_OPTIONS); | 116 | $this->gridSingleSelect('status', '提现状态', WithdrawRecord::STATUS_OPTIONS, WithdrawRecord::STATUS_COLOR_OPTIONS); |
112 | $this->gridDateField('created_at', '提现时间'); | 117 | $this->gridDateField('created_at', '提现时间'); |
113 | $this->gridDateField('audited_at', '审核时间'); | 118 | $this->gridDateField('audited_at', '审核时间'); |
@@ -226,6 +226,11 @@ Route::group([ | @@ -226,6 +226,11 @@ Route::group([ | ||
226 | $router->post('{id}/labels', 'CategoriesController@addLabel')->where('id', '[0-9]+'); | 226 | $router->post('{id}/labels', 'CategoriesController@addLabel')->where('id', '[0-9]+'); |
227 | $router->delete('{id}/labels', 'CategoriesController@deleteLabel')->where('id', '[0-9]+'); | 227 | $router->delete('{id}/labels', 'CategoriesController@deleteLabel')->where('id', '[0-9]+'); |
228 | 228 | ||
229 | + $router->get('{id}/child', 'CategoriesController@childPage')->where('id', '[0-9]+'); | ||
230 | + $router->get('{id}/children', 'CategoriesController@children')->where('id', '[0-9]+'); | ||
231 | + $router->post('{id}/children', 'CategoriesController@addChild')->where('id', '[0-9]+'); | ||
232 | + $router->delete('{id}/labels', 'CategoriesController@deleteLabel')->where('id', '[0-9]+'); | ||
233 | + | ||
229 | // $router->get('{id}/label-item', 'CategoriesController@labelItemPage')->where('id', '[0-9]+'); | 234 | // $router->get('{id}/label-item', 'CategoriesController@labelItemPage')->where('id', '[0-9]+'); |
230 | // $router->post('{id}/label-items', 'CategoriesController@addLabelItem')->where('id', '[0-9]+'); | 235 | // $router->post('{id}/label-items', 'CategoriesController@addLabelItem')->where('id', '[0-9]+'); |
231 | // $router->delete('{id}/label-items', 'CategoriesController@deleteLabelItem')->where('id', '[0-9]+'); | 236 | // $router->delete('{id}/label-items', 'CategoriesController@deleteLabelItem')->where('id', '[0-9]+'); |
@@ -42,6 +42,17 @@ class Handler extends ExceptionHandler | @@ -42,6 +42,17 @@ class Handler extends ExceptionHandler | ||
42 | */ | 42 | */ |
43 | public function report(Throwable $exception) | 43 | public function report(Throwable $exception) |
44 | { | 44 | { |
45 | +// // 捕获异常:路由不存在 No query results for model [App\\Models\ | ||
46 | +// if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { | ||
47 | +// //捕获路由模型绑定在数据库中找不到模型后抛出的NotFoundHttpException | ||
48 | +// return Response::json( | ||
49 | +// [ | ||
50 | +// 'code' => 1001, | ||
51 | +// 'msg' => '该路由不存在!', | ||
52 | +// 'data' => null, | ||
53 | +// ] | ||
54 | +// ); | ||
55 | +// } | ||
45 | parent::report($exception); | 56 | parent::report($exception); |
46 | } | 57 | } |
47 | 58 |
@@ -16,6 +16,9 @@ | @@ -16,6 +16,9 @@ | ||
16 | */ | 16 | */ |
17 | namespace App\Factories\Wechat; | 17 | namespace App\Factories\Wechat; |
18 | 18 | ||
19 | +use EasyWeChat\Factory; | ||
20 | +use Illuminate\Http\Request; | ||
21 | + | ||
19 | /** | 22 | /** |
20 | * Trait Official | 23 | * Trait Official |
21 | * | 24 | * |
@@ -29,6 +32,40 @@ namespace App\Factories\Wechat; | @@ -29,6 +32,40 @@ namespace App\Factories\Wechat; | ||
29 | */ | 32 | */ |
30 | trait Official | 33 | trait Official |
31 | { | 34 | { |
35 | + | ||
36 | + /** | ||
37 | + * 通过code获取用户session信息 | ||
38 | + * | ||
39 | + * @return mixed | ||
40 | + */ | ||
41 | + public function loginOfficialAccount() | ||
42 | + { | ||
43 | + return $this->official->oauth->user(); | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * @param null $config | ||
48 | + * @return $this | ||
49 | + */ | ||
50 | + public function setOfficialAccountConfigure($config = null) | ||
51 | + { | ||
52 | + if (!$config) { | ||
53 | + $config = $this->getOfficialAccountConfigure(); | ||
54 | + } | ||
55 | + | ||
56 | + $this->official = Factory::officialAccount($config); | ||
57 | + | ||
58 | + return $this; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * @return array|bool | ||
63 | + */ | ||
64 | + public function getOfficialAccountConfigure() | ||
65 | + { | ||
66 | + return config('wechat.official_account.default'); | ||
67 | + } | ||
68 | + | ||
32 | /** | 69 | /** |
33 | * 消息发送 | 70 | * 消息发送 |
34 | * | 71 | * |
@@ -47,7 +47,7 @@ class WechatFactory | @@ -47,7 +47,7 @@ class WechatFactory | ||
47 | public function __construct() | 47 | public function __construct() |
48 | { | 48 | { |
49 | // $this->payment = app('wechat.payment'); | 49 | // $this->payment = app('wechat.payment'); |
50 | -// $this->official = app('wechat.official_account'); | 50 | + $this->official = app('wechat.official_account'); |
51 | $this->mini = app('wechat.mini_program'); | 51 | $this->mini = app('wechat.mini_program'); |
52 | } | 52 | } |
53 | 53 |
@@ -55,6 +55,12 @@ class LoginRequest extends BaseRequest | @@ -55,6 +55,12 @@ class LoginRequest extends BaseRequest | ||
55 | 'encryptedData' => 'required', | 55 | 'encryptedData' => 'required', |
56 | 'iv' => 'required', | 56 | 'iv' => 'required', |
57 | ]; | 57 | ]; |
58 | + case User::WECHAT_OFFICIAL_ACCOUNT_AUTHORIZED_LOGIN: | ||
59 | + return [ | ||
60 | + 'code' => 'required', | ||
61 | +// 'encryptedData' => 'required', | ||
62 | +// 'iv' => 'required', | ||
63 | + ]; | ||
58 | default: | 64 | default: |
59 | return [ | 65 | return [ |
60 | 'mobile' => 'required', | 66 | 'mobile' => 'required', |
@@ -18,6 +18,7 @@ namespace App\Models\Category; | @@ -18,6 +18,7 @@ namespace App\Models\Category; | ||
18 | 18 | ||
19 | use App\Models\BaseModel; | 19 | use App\Models\BaseModel; |
20 | use GuzzleHttp\Exception\GuzzleException; | 20 | use GuzzleHttp\Exception\GuzzleException; |
21 | +use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
21 | use Illuminate\Database\Eloquent\Relations\HasMany; | 22 | use Illuminate\Database\Eloquent\Relations\HasMany; |
22 | 23 | ||
23 | /** | 24 | /** |
@@ -69,6 +70,22 @@ class Category extends BaseModel | @@ -69,6 +70,22 @@ class Category extends BaseModel | ||
69 | } | 70 | } |
70 | 71 | ||
71 | /** | 72 | /** |
73 | + * @return BelongsTo | ||
74 | + */ | ||
75 | + public function parent(): BelongsTo | ||
76 | + { | ||
77 | + return $this->belongsTo(get_class($this), 'pid', 'id'); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * @return HasMany | ||
82 | + */ | ||
83 | + public function children(): HasMany | ||
84 | + { | ||
85 | + return $this->hasMany(get_class($this), 'pid', 'id'); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
72 | * @param $value | 89 | * @param $value |
73 | */ | 90 | */ |
74 | public function setIconAttribute($value) | 91 | public function setIconAttribute($value) |
@@ -87,4 +104,27 @@ class Category extends BaseModel | @@ -87,4 +104,27 @@ class Category extends BaseModel | ||
87 | { | 104 | { |
88 | return splice_file_path($value); | 105 | return splice_file_path($value); |
89 | } | 106 | } |
107 | + | ||
108 | + | ||
109 | + /** | ||
110 | + * 生成每个级别的code | ||
111 | + * @param string $oprate | ||
112 | + * @return array | ||
113 | + */ | ||
114 | + public static function getParents($oprate = 'query') | ||
115 | + { | ||
116 | + $models = self::where(function ($query) { | ||
117 | + $query->whereNull('pid')->orWhere('pid', 0)->orWhere('pid', ''); | ||
118 | + })->get(['id','name']); | ||
119 | + $options = []; | ||
120 | + if ($oprate !== 'query') { | ||
121 | + $options = [0 => '无']; | ||
122 | + } | ||
123 | + foreach ($models as $vo) { | ||
124 | + $options[$vo->id] = $vo->name; | ||
125 | + } | ||
126 | + return $options; | ||
127 | + return $models; | ||
128 | + } | ||
129 | + | ||
90 | } | 130 | } |
@@ -41,8 +41,8 @@ class RechargeOrder extends BaseModel | @@ -41,8 +41,8 @@ class RechargeOrder extends BaseModel | ||
41 | /** | 41 | /** |
42 | * 支付方式代码集 | 42 | * 支付方式代码集 |
43 | */ | 43 | */ |
44 | - const WECHAT_PAY = 1;// 微信支付 | ||
45 | - const H5_PAY = 2;// H5支付 | 44 | + const WECHAT_PAY = 2;// 微信支付 |
45 | + const H5_PAY = 1;// H5支付 | ||
46 | const PAY_TYPE_OPTIONS = [ | 46 | const PAY_TYPE_OPTIONS = [ |
47 | self::WECHAT_PAY => '微信支付', | 47 | self::WECHAT_PAY => '微信支付', |
48 | self::H5_PAY => 'H5支付', | 48 | self::H5_PAY => 'H5支付', |
@@ -51,6 +51,11 @@ use Tymon\JWTAuth\Contracts\JWTSubject; | @@ -51,6 +51,11 @@ use Tymon\JWTAuth\Contracts\JWTSubject; | ||
51 | * @property mixed role | 51 | * @property mixed role |
52 | * @property mixed house_number | 52 | * @property mixed house_number |
53 | * @property mixed address | 53 | * @property mixed address |
54 | + * @property int|mixed pid | ||
55 | + * @property int|mixed gid | ||
56 | + * @property mixed openid | ||
57 | + * @property mixed registered_ip | ||
58 | + * @property int|mixed times | ||
54 | */ | 59 | */ |
55 | class User extends Authenticatable implements JWTSubject | 60 | class User extends Authenticatable implements JWTSubject |
56 | { | 61 | { |
@@ -77,12 +77,14 @@ class WithdrawRecord extends BaseModel | @@ -77,12 +77,14 @@ class WithdrawRecord extends BaseModel | ||
77 | self::FAILED => 'info', | 77 | self::FAILED => 'info', |
78 | ]; | 78 | ]; |
79 | 79 | ||
80 | + | ||
81 | + const RATIO = 1;// 提现手续费 | ||
80 | /** | 82 | /** |
81 | * 访问器被附加到模型数组的形式。 | 83 | * 访问器被附加到模型数组的形式。 |
82 | * | 84 | * |
83 | * @var array | 85 | * @var array |
84 | */ | 86 | */ |
85 | - protected $appends = ['status_show', 'type_show']; | 87 | + protected $appends = ['status_show', 'type_show', 'actual_amount']; |
86 | 88 | ||
87 | /** | 89 | /** |
88 | * @return BelongsTo | 90 | * @return BelongsTo |
@@ -140,4 +142,13 @@ class WithdrawRecord extends BaseModel | @@ -140,4 +142,13 @@ class WithdrawRecord extends BaseModel | ||
140 | return Arr::get(self::TYPE_OPTIONS, $this->type ? : self::BANK); | 142 | return Arr::get(self::TYPE_OPTIONS, $this->type ? : self::BANK); |
141 | } | 143 | } |
142 | 144 | ||
145 | + /** | ||
146 | + * 获取类型的中文显示 | ||
147 | + * | ||
148 | + * @return mixed | ||
149 | + */ | ||
150 | + public function getActualAmountAttribute() | ||
151 | + { | ||
152 | + return $this->amount * (100 - $this->ratio) / 100; | ||
153 | + } | ||
143 | } | 154 | } |
@@ -36,8 +36,29 @@ class AppServiceProvider extends ServiceProvider | @@ -36,8 +36,29 @@ class AppServiceProvider extends ServiceProvider | ||
36 | return response()->json(['code'=>1001,'msg'=>'暂无相关数据!','data'=> null ], 200); | 36 | return response()->json(['code'=>1001,'msg'=>'暂无相关数据!','data'=> null ], 200); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | + // 公众号收取失败异常捕获 | ||
40 | + API::error(function (\Overtrue\Socialite\AuthorizeFailedException $exception) { | ||
41 | + return response()->json(['code'=>2004,'msg'=> $exception->getMessage(),'data'=> null ], 200); | ||
42 | + }); | ||
43 | + | ||
44 | + API::error(function (\Exception $exception) { | ||
45 | + dd($exception); | ||
46 | + return response()->json(['code'=>2004,'msg'=> $exception->getMessage(),'data'=> null ], 200); | ||
47 | + }); | ||
39 | 48 | ||
40 | - // add by Richer 于 2022年9月26日15:35:05 增加路由不存在的异常捕获 | 49 | +// // 捕获异常:路由不存在 No query results for model [App\\Models\ |
50 | +// if ($exception instanceof NotFoundHttpException) { | ||
51 | +// //捕获路由模型绑定在数据库中找不到模型后抛出的NotFoundHttpException | ||
52 | +// return Response::json( | ||
53 | +// [ | ||
54 | +// 'code' => 1, | ||
55 | +// 'msg' => '该路由不存在!', | ||
56 | +// 'data' => null, | ||
57 | +// ] | ||
58 | +// ); | ||
59 | +// } | ||
60 | +// | ||
61 | +// // add by Richer 于 2022年9月26日15:35:05 增加路由不存在的异常捕获 | ||
41 | // \API::error(function (FatalErrorException $exception) { | 62 | // \API::error(function (FatalErrorException $exception) { |
42 | API::error(function (FatalErrorException $exception) { | 63 | API::error(function (FatalErrorException $exception) { |
43 | return response()->json(['code'=>1001,'msg'=>'路由不存在!','data'=> null ], 200); | 64 | return response()->json(['code'=>1001,'msg'=>'路由不存在!','data'=> null ], 200); |
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | */ | 16 | */ |
17 | namespace App\Services; | 17 | namespace App\Services; |
18 | 18 | ||
19 | +use App\Http\Requests\LoginRequest; | ||
19 | use App\Models\System\SmsLog; | 20 | use App\Models\System\SmsLog; |
20 | use App\Models\User\Role; | 21 | use App\Models\User\Role; |
21 | use App\Models\User\User; | 22 | use App\Models\User\User; |
@@ -23,6 +24,7 @@ use App\Models\User\LoginRecord as UserLoginRecord; | @@ -23,6 +24,7 @@ use App\Models\User\LoginRecord as UserLoginRecord; | ||
23 | use Browser; | 24 | use Browser; |
24 | use Illuminate\Http\Request; | 25 | use Illuminate\Http\Request; |
25 | use Illuminate\Support\Arr; | 26 | use Illuminate\Support\Arr; |
27 | +use Illuminate\Support\Facades\DB; | ||
26 | use Illuminate\Support\Facades\Hash; | 28 | use Illuminate\Support\Facades\Hash; |
27 | use JWTAuth; | 29 | use JWTAuth; |
28 | 30 | ||
@@ -117,6 +119,7 @@ class AuthService extends BaseService | @@ -117,6 +119,7 @@ class AuthService extends BaseService | ||
117 | */ | 119 | */ |
118 | public function login($request) | 120 | public function login($request) |
119 | { | 121 | { |
122 | + try { | ||
120 | switch ($request->login_method) { | 123 | switch ($request->login_method) { |
121 | case 'mobile': | 124 | case 'mobile': |
122 | return $this->loginWithMobile($request); | 125 | return $this->loginWithMobile($request); |
@@ -132,7 +135,7 @@ class AuthService extends BaseService | @@ -132,7 +135,7 @@ class AuthService extends BaseService | ||
132 | break; | 135 | break; |
133 | case User::WECHAT_OFFICIAL_ACCOUNT_AUTHORIZED_LOGIN: | 136 | case User::WECHAT_OFFICIAL_ACCOUNT_AUTHORIZED_LOGIN: |
134 | $service = app(WechatService::class); | 137 | $service = app(WechatService::class); |
135 | - $result = $service->auth($request); | 138 | + $result = $service->authLoginWithOfficialAccount($request); |
136 | break; | 139 | break; |
137 | default: | 140 | default: |
138 | return $this->loginWithPassword($request); | 141 | return $this->loginWithPassword($request); |
@@ -142,6 +145,18 @@ class AuthService extends BaseService | @@ -142,6 +145,18 @@ class AuthService extends BaseService | ||
142 | $this->message = $service->getMessage(); | 145 | $this->message = $service->getMessage(); |
143 | } | 146 | } |
144 | return $result; | 147 | return $result; |
148 | + } catch (\Exception $exception) { | ||
149 | + $this->message = $exception->getMessage(); | ||
150 | +// dump($exception->g); | ||
151 | +// dump($exception->getMessage()); | ||
152 | +// dump($exception->getCode()); | ||
153 | + $message = $exception->getMessage(); | ||
154 | +// if (Str::contains($message, '"errcode":40125')) { | ||
155 | +// $this->message = 'AppSecret '.__('invalid'); | ||
156 | +// } | ||
157 | + | ||
158 | + return false; | ||
159 | + } | ||
145 | } | 160 | } |
146 | 161 | ||
147 | /** | 162 | /** |
@@ -293,16 +308,29 @@ class AuthService extends BaseService | @@ -293,16 +308,29 @@ class AuthService extends BaseService | ||
293 | "headimgurl" => "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eobkqbPCsjImL5qk7ErZxrRQg34FpGqnbpUwiau6ibNIA9CWic53dwCXPjjECLFqXqRh5gXGLYrjHzoQ/132" | 308 | "headimgurl" => "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eobkqbPCsjImL5qk7ErZxrRQg34FpGqnbpUwiau6ibNIA9CWic53dwCXPjjECLFqXqRh5gXGLYrjHzoQ/132" |
294 | "privilege" => [] | 309 | "privilege" => [] |
295 | * | 310 | * |
296 | - * @param LoginPost $request request | 311 | + * @param LoginRequest $request request |
297 | * | 312 | * |
298 | * @return bool|string | 313 | * @return bool|string |
299 | * @throws \Exception | 314 | * @throws \Exception |
300 | */ | 315 | */ |
301 | public function wechatAuth($request) | 316 | public function wechatAuth($request) |
302 | { | 317 | { |
318 | + try { | ||
319 | + $service = app(WechatService::class); | ||
320 | + $result = $service->authLoginWithOfficialAccount($request); | ||
321 | + if (!$result) { | ||
322 | + $this->message = $service->getMessage(); | ||
323 | + } | ||
324 | + } catch (\Exception $exception) { | ||
325 | + $this->message = $exception->getMessage(); | ||
326 | + return false; | ||
327 | + } | ||
328 | + | ||
329 | + $service = app(WechatService::class); | ||
330 | + | ||
303 | // 开启事务 | 331 | // 开启事务 |
304 | -// DB::beginTransaction(); | ||
305 | -// try { | 332 | + DB::beginTransaction(); |
333 | + try { | ||
306 | // 正在申请 | 334 | // 正在申请 |
307 | $userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 | 335 | $userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 |
308 | 336 | ||
@@ -352,10 +380,10 @@ class AuthService extends BaseService | @@ -352,10 +380,10 @@ class AuthService extends BaseService | ||
352 | return $user; | 380 | return $user; |
353 | 381 | ||
354 | // all good | 382 | // all good |
355 | -// } catch (\Exception $e) { | ||
356 | -// DB::rollback(); | ||
357 | -// return false; | ||
358 | -// } | 383 | + } catch (\Exception $e) { |
384 | + DB::rollback(); | ||
385 | + return false; | ||
386 | + } | ||
359 | } | 387 | } |
360 | 388 | ||
361 | /** | 389 | /** |
@@ -42,12 +42,16 @@ class CategoryService extends BaseService | @@ -42,12 +42,16 @@ class CategoryService extends BaseService | ||
42 | */ | 42 | */ |
43 | public function list() | 43 | public function list() |
44 | { | 44 | { |
45 | - return $this->model | 45 | + return $this->model->with(['children']) |
46 | + ->where(function ($query) { | ||
47 | + $query->whereNull('pid')->orWhere('pid', 0)->orWhere('pid', ''); | ||
48 | + }) | ||
46 | ->when($q = request('name'), function ($query) use ($q) { | 49 | ->when($q = request('name'), function ($query) use ($q) { |
47 | $query->where("name", 'like', "%$q%"); | 50 | $query->where("name", 'like', "%$q%"); |
48 | }) | 51 | }) |
49 | ->where('status', 1) | 52 | ->where('status', 1) |
50 | ->orderBy('sort') | 53 | ->orderBy('sort') |
54 | + ->groupBy('id') | ||
51 | ->latest() | 55 | ->latest() |
52 | ->get(); | 56 | ->get(); |
53 | } | 57 | } |
@@ -164,7 +164,7 @@ class RechargeOrderService extends BaseService | @@ -164,7 +164,7 @@ class RechargeOrderService extends BaseService | ||
164 | // 更新数据库状态 | 164 | // 更新数据库状态 |
165 | if ($order->status == RechargeOrder::UNPAID) { | 165 | if ($order->status == RechargeOrder::UNPAID) { |
166 | $order->status = RechargeOrder::PAID; | 166 | $order->status = RechargeOrder::PAID; |
167 | - $order->paid_type = RechargeOrder::WECHAT_PAY; | 167 | + $order->paid_type = RechargeOrder::H5_PAY; |
168 | $order->paid_at = $paid_at; | 168 | $order->paid_at = $paid_at; |
169 | $order->paid_info = $data; | 169 | $order->paid_info = $data; |
170 | $result = $order->save(); | 170 | $result = $order->save(); |
@@ -111,7 +111,7 @@ class RechargePackageService extends BaseService | @@ -111,7 +111,7 @@ class RechargePackageService extends BaseService | ||
111 | // $pay['notify_url'] = $notify_url; | 111 | // $pay['notify_url'] = $notify_url; |
112 | // } | 112 | // } |
113 | // 更新订单 | 113 | // 更新订单 |
114 | - $type = RechargeOrder::WECHAT_PAY; | 114 | + $type = RechargeOrder::H5_PAY; |
115 | $order->out_trade_no = $out_trade_no; | 115 | $order->out_trade_no = $out_trade_no; |
116 | $model->paid_type = $type; | 116 | $model->paid_type = $type; |
117 | $order->save(); | 117 | $order->save(); |
@@ -528,6 +528,10 @@ class UserService extends BaseService | @@ -528,6 +528,10 @@ class UserService extends BaseService | ||
528 | $wallet = $user->getWallet(); | 528 | $wallet = $user->getWallet(); |
529 | 529 | ||
530 | $amount = $request->amount; | 530 | $amount = $request->amount; |
531 | + if ($amount < 100) { | ||
532 | + $this->message = '提现失败,最少提现 100 元。'; | ||
533 | + return false; | ||
534 | + } | ||
531 | // 判断金额 | 535 | // 判断金额 |
532 | if ($wallet->balance < $amount) { | 536 | if ($wallet->balance < $amount) { |
533 | $this->message = '提现失败,账户余额不足。'; | 537 | $this->message = '提现失败,账户余额不足。'; |
@@ -535,10 +539,10 @@ class UserService extends BaseService | @@ -535,10 +539,10 @@ class UserService extends BaseService | ||
535 | } | 539 | } |
536 | 540 | ||
537 | // 最低需要保留1元 | 541 | // 最低需要保留1元 |
538 | - if ($wallet->balance - $amount < 1) { | ||
539 | - $this->message = '提现失败,账户最少需要保留 1 元。'; | ||
540 | - return false; | ||
541 | - } | 542 | +// if ($wallet->balance - $amount < 1) { |
543 | +// $this->message = '提现失败,账户最少需要保留 1 元。'; | ||
544 | +// return false; | ||
545 | +// } | ||
542 | 546 | ||
543 | // 判断是否有还未审核通过的提现记录 | 547 | // 判断是否有还未审核通过的提现记录 |
544 | if ($user->withdrawals()->where('status', WithdrawRecord::UNAUDITED)->first()) { | 548 | if ($user->withdrawals()->where('status', WithdrawRecord::UNAUDITED)->first()) { |
@@ -553,6 +557,7 @@ class UserService extends BaseService | @@ -553,6 +557,7 @@ class UserService extends BaseService | ||
553 | 557 | ||
554 | $data = $request->all(); | 558 | $data = $request->all(); |
555 | $data['bank_name'] = $bank_name; | 559 | $data['bank_name'] = $bank_name; |
560 | + $data['ratio'] = WithdrawRecord::RATIO; | ||
556 | 561 | ||
557 | $withdrawal = $user->withdrawals()->create($data); | 562 | $withdrawal = $user->withdrawals()->create($data); |
558 | 563 |
@@ -403,69 +403,90 @@ class WechatService extends BaseService | @@ -403,69 +403,90 @@ class WechatService extends BaseService | ||
403 | "headimgurl" => "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eobkqbPCsjImL5qk7ErZxrRQg34FpGqnbpUwiau6ibNIA9CWic53dwCXPjjECLFqXqRh5gXGLYrjHzoQ/132" | 403 | "headimgurl" => "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eobkqbPCsjImL5qk7ErZxrRQg34FpGqnbpUwiau6ibNIA9CWic53dwCXPjjECLFqXqRh5gXGLYrjHzoQ/132" |
404 | "privilege" => [] | 404 | "privilege" => [] |
405 | * | 405 | * |
406 | - * @param LoginPost $request request | 406 | + * @param $request request |
407 | * | 407 | * |
408 | * @return bool|string | 408 | * @return bool|string |
409 | * @throws \Exception | 409 | * @throws \Exception |
410 | + * | ||
410 | */ | 411 | */ |
411 | - public function loginWithOfficialAccount($request) | 412 | + public function authLoginWithOfficialAccount($request) |
412 | { | 413 | { |
413 | - // 开启事务 | ||
414 | -// DB::beginTransaction(); | ||
415 | -// try { | ||
416 | // 正在申请 | 414 | // 正在申请 |
417 | - $userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 | 415 | + $user_info = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 |
416 | + | ||
417 | + | ||
418 | +// $factory = app(WechatFactory::class); | ||
419 | +// // 公众号好手气 | ||
420 | +// $user_info = $factory->setOfficialAccountConfigure()->loginOfficialAccount()->original; | ||
421 | +// | ||
422 | +// // 拿到静默获取的openid, 静默获取只能获取openid 点击按钮可以获取详细信息 | ||
423 | +//// $user = $app->user->get($openid); | ||
424 | + | ||
425 | + $openid = Arr::get($user_info, 'openid'); | ||
426 | +// $user = $app->oauth->user()->toArray(); | ||
427 | + | ||
428 | + // 正在申请 | ||
429 | +// $userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 | ||
418 | 430 | ||
419 | // 获取授权参数 | 431 | // 获取授权参数 |
420 | - $openid = Arr::get($userinfo, 'openid'); | ||
421 | $user = null; | 432 | $user = null; |
433 | + | ||
422 | if ($openid) { | 434 | if ($openid) { |
423 | - // TODO 测试登录其他账号 | ||
424 | - if ($openid == 'osLHa6ruNfzBQKTUryvQs8q02Cmw') { | ||
425 | - //$openid = 'osLHa6oDbwJk0XCN7jqojQbY9lO4'; | ||
426 | - } | ||
427 | $user = User::where('openid', $openid)->first(); | 435 | $user = User::where('openid', $openid)->first(); |
428 | } | 436 | } |
429 | 437 | ||
430 | - if ($user) { | ||
431 | - $token = JWTAuth::fromuser($user); | ||
432 | - $user->token = $token; | 438 | + if (!$user) { |
439 | + $user = $this->createUser($request, $openid); | ||
440 | + } | ||
441 | + | ||
442 | + if ($user_info) { | ||
443 | + $user->avatar = Arr::get($user_info, 'avatarUrl'); | ||
444 | + $user->nickname = Arr::get($user_info, 'nickName'); | ||
445 | + $user->gender = Arr::get($user_info, 'gender'); | ||
446 | + $user->country = Arr::get($user_info, 'country'); | ||
447 | + $user->province = Arr::get($user_info, 'province'); | ||
448 | + $user->city = Arr::get($user_info, 'city'); | ||
449 | + } | ||
450 | + $user->token = JWTAuth::fromuser($user); | ||
433 | $user->save(); | 451 | $user->save(); |
452 | + | ||
453 | + // 记录登陆日志 | ||
454 | + $this->recordLoginRecord($request, $user); | ||
434 | return $user; | 455 | return $user; |
435 | - } else { | ||
436 | - $data['openid'] = $openid; | ||
437 | - $data['nickname'] = Arr::get($userinfo, 'nickname'); | ||
438 | - $data['avatar'] = Arr::get($userinfo, 'headimgurl'); | ||
439 | - $data['gender'] = Arr::get($userinfo, 'gender'); | ||
440 | - return $data; | 456 | + } |
457 | + | ||
458 | + /** | ||
459 | + * 创建用户 | ||
460 | + * | ||
461 | + * @param $request | ||
462 | + * @param $openid | ||
463 | + * @param string $mobile | ||
464 | + * @return User | ||
465 | + */ | ||
466 | + public function createUser($request, $openid, $mobile = '') | ||
467 | + { | ||
441 | $user = new User(); | 468 | $user = new User(); |
469 | + // 创建用户 | ||
470 | + $pid = $request->inviter_id ? : 0; // 邀请人id | ||
471 | + $gid = 0; | ||
472 | + if ($pid) { | ||
473 | + $inviter = User::find($pid); | ||
474 | + $gid = optional($inviter)->pid; | ||
475 | + } | ||
476 | + $user->times = 10; // 新用户注册赠送 10 条 | ||
477 | + $user->username = $mobile; | ||
478 | + $user->pid = $pid; | ||
479 | + $user->gid = $gid; | ||
480 | + $user->username = $mobile; | ||
481 | + $user->mobile = $mobile; | ||
442 | $user->openid = $openid; | 482 | $user->openid = $openid; |
443 | - $user->nickname = Arr::get($userinfo, 'nickname'); | ||
444 | - $user->avatar = Arr::get($userinfo, 'headimgurl'); | ||
445 | - $user->gender = Arr::get($userinfo, 'gender'); | ||
446 | - $user->country = Arr::get($userinfo, 'country'); | ||
447 | - $user->province = Arr::get($userinfo, 'province'); | ||
448 | - $user->city = Arr::get($userinfo, 'city'); | 483 | + $user->password = bcrypt(config('constants.PASSWORD')); |
449 | $user->role = Role::GENERAL; | 484 | $user->role = Role::GENERAL; |
450 | $user->password = bcrypt(config('constants.PASSWORD')); | 485 | $user->password = bcrypt(config('constants.PASSWORD')); |
451 | $user->registered_at = date('Y-m-d H:i:s'); | 486 | $user->registered_at = date('Y-m-d H:i:s'); |
452 | $user->registered_ip = $request->ip(); | 487 | $user->registered_ip = $request->ip(); |
453 | - $result = $user->save(); | ||
454 | - $token = JWTAuth::fromuser($user); | ||
455 | - $user->token = $token; | ||
456 | - $user->save(); | ||
457 | - } | ||
458 | - | ||
459 | - // 记录登陆日志 | ||
460 | - $this->recordLoginRecord($request, $user); | ||
461 | 488 | ||
462 | return $user; | 489 | return $user; |
463 | - | ||
464 | - // all good | ||
465 | -// } catch (\Exception $e) { | ||
466 | -// DB::rollback(); | ||
467 | -// return false; | ||
468 | -// } | ||
469 | } | 490 | } |
470 | 491 | ||
471 | /** | 492 | /** |
@@ -46,7 +46,24 @@ class CategoryTransformer extends BaseTransformer | @@ -46,7 +46,24 @@ class CategoryTransformer extends BaseTransformer | ||
46 | 'status' => (int)$model->status, | 46 | 'status' => (int)$model->status, |
47 | 'status_show' => (string)$model->status_show, | 47 | 'status_show' => (string)$model->status_show, |
48 | 'created_at' => format_date($model->created_at), | 48 | 'created_at' => format_date($model->created_at), |
49 | - 'updated_at' => format_date($model->updated_at), | 49 | +// 'updated_at' => format_date($model->updated_at), |
50 | + 'children' => $model->children->map(function ($child) { | ||
51 | + return [ | ||
52 | + 'id' => (int) $child->id, | ||
53 | + | ||
54 | + /* place your other model properties here */ | ||
55 | + 'name' => (string)$child->name, | ||
56 | + 'icon' => $child->icon, | ||
57 | + 'body' => (string)$child->body, | ||
58 | + 'description' => (string)$child->description, | ||
59 | + | ||
60 | + 'sort' => (int)$child->sort, | ||
61 | + 'status' => (int)$child->status, | ||
62 | + 'status_show' => (string)$child->status_show, | ||
63 | + 'created_at' => format_date($child->created_at), | ||
64 | +// 'updated_at' => format_date($child->updated_at), | ||
65 | + ]; | ||
66 | + }) | ||
50 | ]; | 67 | ]; |
51 | } | 68 | } |
52 | } | 69 | } |
@@ -106,7 +106,7 @@ return [ | @@ -106,7 +106,7 @@ return [ | ||
106 | | If your page is going to be accessed via https, set it to `true`. | 106 | | If your page is going to be accessed via https, set it to `true`. |
107 | | | 107 | | |
108 | */ | 108 | */ |
109 | - 'https' => env('ADMIN_HTTPS', true), | 109 | + 'https' => env('ADMIN_HTTPS', false), |
110 | 110 | ||
111 | /* | 111 | /* |
112 | |-------------------------------------------------------------------------- | 112 | |-------------------------------------------------------------------------- |
@@ -31,7 +31,7 @@ return [ | @@ -31,7 +31,7 @@ return [ | ||
31 | 31 | ||
32 | 'wechat' => [ | 32 | 'wechat' => [ |
33 | // 公众号 APPID | 33 | // 公众号 APPID |
34 | - 'app_id' => env('WECHAT_MINI_APPID', 'wx3bb38a6c1cb0ed8c'), | 34 | + 'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', 'wx3bb38a6c1cb0ed8c'), |
35 | 35 | ||
36 | // APP 引用的 appid | 36 | // APP 引用的 appid |
37 | 'appid' => env('WECHAT_MINI_APPID', 'wx3bb38a6c1cb0ed8c'), | 37 | 'appid' => env('WECHAT_MINI_APPID', 'wx3bb38a6c1cb0ed8c'), |
@@ -1713,3 +1713,9 @@ a, address, b, big, blockquote, body, center, cite, code, dd, del, div, dl, dt, | @@ -1713,3 +1713,9 @@ a, address, b, big, blockquote, body, center, cite, code, dd, del, div, dl, dt, | ||
1713 | /* line-height: 1.5!important;*/ | 1713 | /* line-height: 1.5!important;*/ |
1714 | /* border-radius: 3px!important;*/ | 1714 | /* border-radius: 3px!important;*/ |
1715 | /*}*/ | 1715 | /*}*/ |
1716 | +.cascade-group .form-group{ | ||
1717 | + padding-top: 15px!important; | ||
1718 | +} | ||
1719 | +.cascade-group label.col-form-label { | ||
1720 | + padding-left:55px!important; | ||
1721 | +} |
1 | +<!DOCTYPE html> | ||
2 | +<html lang="{{ config('app.locale') }}"> | ||
3 | +<head> | ||
4 | + <meta charset="utf-8"> | ||
5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
6 | + <meta name="csrf-token" content="{{ csrf_token() }}"> | ||
7 | + <title></title> | ||
8 | + <!-- Tell the browser to be responsive to screen width --> | ||
9 | + <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> | ||
10 | + | ||
11 | + {!! Admin::css() !!} | ||
12 | + | ||
13 | + <script src="{{ Admin::jQuery() }}"></script> | ||
14 | + | ||
15 | + {!! Admin::headerJs() !!} | ||
16 | + <!--[if lt IE 9]> | ||
17 | + <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> | ||
18 | + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
19 | + <![endif]--> | ||
20 | + | ||
21 | + <link type="text/css" rel="stylesheet" href="/vendor/laravel-admin/toastr/build/toastr.min.css"/> | ||
22 | + <script src="/vendor/laravel-admin/toastr/build/toastr.min.js"></script> | ||
23 | + <script src="/vendor/laravel-admin/jquery-pjax/jquery.pjax.js"></script> | ||
24 | + <script src="/assets/layer-v3.1.1/layer/layer.js"></script> | ||
25 | + <script src="/assets/layui/layui.js"></script> | ||
26 | + <script src="/vendor/laravel-admin/sweetalert2/dist/sweetalert2.min.js"></script> | ||
27 | + <script src="{{ admin_asset("vendor/laravel-admin/AdminLTE/plugins/iCheck/icheck.min.js")}}"></script> | ||
28 | + <script src="/assets/admin/js/main.js"></script> | ||
29 | + <script src="/assets/admin/js/common.js?1"></script> | ||
30 | + | ||
31 | + | ||
32 | + <link rel="stylesheet" type="text/css" href="/vendor/laravel-admin/AdminLTE/plugins/select2/select2.min.css" /> | ||
33 | + <script src="/vendor/laravel-admin/AdminLTE/plugins/select2/select2.full.min.js"></script> | ||
34 | + <link type="text/css" rel="stylesheet" href="/assets/admin/css/main.css?11111111"/> | ||
35 | + <link type="text/css" rel="stylesheet" href="/vendor/laravel-admin/sweetalert2/dist/sweetalert2.css"/> | ||
36 | + <link rel="stylesheet" href="{{ admin_asset("vendor/laravel-admin/AdminLTE/plugins/iCheck/square/blue.css") }}"> | ||
37 | +</head> | ||
38 | +<body class="hold-transition"> | ||
39 | +<div class="wrapper"> | ||
40 | + {{-- <form action="categories/{{$id}}/labels" method="post" accept-charset="UTF-8" class="" enctype="multipart/form-data" pjax-container="">--}} | ||
41 | + <div class="box-body"> | ||
42 | + <div class="fields-group"> | ||
43 | + <div class="col-sm-12"> | ||
44 | + <div class="form-group col-sm-12 clear-both row " style="clear:both;"> | ||
45 | + <label for="name" class="col-sm-2 col-form-label asterisk">名称</label> | ||
46 | + <div class="col-sm-10"> | ||
47 | + <input id="name" name="name" class="form-control name" placeholder="输入 标签名称" value="" required /> | ||
48 | + <span class="form-text text-muted"> | ||
49 | + <i class="fa fa-info-circle"></i> 名称 请勿超过 20 个字 | ||
50 | + </span> | ||
51 | + </div> | ||
52 | + </div> | ||
53 | + | ||
54 | + <div class="form-group col-sm-12 clear-both row " style="clear:both;"> | ||
55 | + <label for="name" class="col-sm-2 col-form-label asterisk">是否可以多选</label> | ||
56 | + <div class="col-sm-10"> | ||
57 | + <span class="icheck"> | ||
58 | + <label class="radio-inline"> | ||
59 | + <input type="radio" name="can_multiple" value="0" class="minimal" {{ optional($label)->can_multiple == 0 ?'checked':'' }}/> 否 | ||
60 | + </label> | ||
61 | + </span> | ||
62 | + <span class="icheck"> | ||
63 | + <label class="radio-inline"> | ||
64 | + <input type="radio" name="can_multiple" value="1" class="minimal" {{ optional($label)->can_multiple == 1 ?'checked':'' }}/> 是 | ||
65 | + </label> | ||
66 | + </span> | ||
67 | + | ||
68 | + </div> | ||
69 | + </div> | ||
70 | + | ||
71 | + {{--<div class="form-group col-sm-12 clear-both row " style="clear:both;"> | ||
72 | + <label for="name" class="col-sm-2 col-form-label asterisk">标签语义</label> | ||
73 | + <div class="col-sm-10"> | ||
74 | + <input id="semantics" name="semantics" class="form-control semantics" placeholder="输入 标签语义" value="{{ optional($label)->semantics }}" required /> | ||
75 | + <span class="form-text text-muted"> | ||
76 | + <i class="fa fa-info-circle"></i> 标签语义 请勿超过 100 个字 | ||
77 | + </span> | ||
78 | + </div> | ||
79 | + </div> | ||
80 | + | ||
81 | + <div class="form-group col-sm-12 clear-both row " style="clear:both;"> | ||
82 | + <label for="description" class="col-sm-2 col-form-label">标签描述</label> | ||
83 | + <div class="col-sm-10"> | ||
84 | + <textarea id="description" name="description" class="form-control description" rows="5" placeholder="输入 标签描述">{{ optional($label)->description }}</textarea> | ||
85 | + <span class="form-text text-muted"> | ||
86 | + <i class="fa fa-info-circle"></i> 回答 请勿超过 255 个字 | ||
87 | + </span> | ||
88 | + </div> | ||
89 | + </div>--}} | ||
90 | + </div> | ||
91 | + </div> | ||
92 | + </div> | ||
93 | + | ||
94 | + <div class="card-footer" style="height: 50px!important;"> | ||
95 | + <div class="col-md-1"></div> | ||
96 | + <div class="col-md-10 col-md-8"> | ||
97 | + <div class="d-flex d-sm-inline-flex align-items-center"> | ||
98 | + <button type="button" class="btn btn-success btn-add">提交</button> | ||
99 | + {{--<button type="submit" class="btn btn-primary">提交</button>--}} | ||
100 | + </div> | ||
101 | + <div class="d-flex d-sm-inline-flex align-items-center"></div> | ||
102 | + </div> | ||
103 | + </div> | ||
104 | + {{-- </form>--}} | ||
105 | +</div> | ||
106 | + | ||
107 | +<script> | ||
108 | + | ||
109 | + $(function () { | ||
110 | + $("input:radio").iCheck({ | ||
111 | + checkboxClass: 'icheckbox_square-blue', | ||
112 | + radioClass: 'iradio_square-green', | ||
113 | + increaseArea: '100%' // optional | ||
114 | + }); | ||
115 | + {{--$("input:radio[name='type']").on('ifChecked', function () {--}} | ||
116 | + {{-- if($(this).val()=="1"){--}} | ||
117 | + {{-- // 短期密码--}} | ||
118 | + {{-- $(this).closest('.fields-group').find('.long-div').hide();--}} | ||
119 | + {{-- $(this).closest('.fields-group').find('.short-div').show();--}} | ||
120 | + {{-- $(this).closest('.fields-group').find('.password').val("{{optional($short_term)->password}}");--}} | ||
121 | + {{-- var short_term_time= "{{$short_term_time}}";--}} | ||
122 | + {{-- $(this).closest('.fields-group').find("input[name='short_term_time'][value='" + short_term_time+ "']").iCheck("check");--}} | ||
123 | + {{-- // var date = new Date();--}} | ||
124 | + {{-- // $('.enabled_at_short').datetimepicker({--}} | ||
125 | + {{-- // "format":"YYYY-MM-DD HH:mm","locale":"zh-CN","allowInputToggle":true,--}} | ||
126 | + {{-- // // minDate: date,--}} | ||
127 | + {{-- // });--}} | ||
128 | + {{-- //--}} | ||
129 | + {{-- // $('.expired_at_short').datetimepicker({--}} | ||
130 | + {{-- // "format":"YYYY-MM-DD HH:m","locale":"zh-CN","allowInputToggle":true,--}} | ||
131 | + {{-- // // minDate: date,--}} | ||
132 | + {{-- // });--}} | ||
133 | + {{-- // 设置选中--}} | ||
134 | + {{-- }if($(this).val()=="2"){--}} | ||
135 | + | ||
136 | + {{-- // 长期密码--}} | ||
137 | + {{-- $(this).closest('.fields-group').find('.long-div').show();--}} | ||
138 | + {{-- $(this).closest('.fields-group').find('.short-div').hide();--}} | ||
139 | + {{-- $(this).closest('.fields-group').find('.password').val("{{optional($long_term)->password}}");--}} | ||
140 | + | ||
141 | + {{-- }--}} | ||
142 | + {{-- // $(this).attr("checked",false);--}} | ||
143 | + | ||
144 | + {{-- $(this).iCheck('update');--}} | ||
145 | + {{--});--}} | ||
146 | + | ||
147 | + $(".btn-add").click(function () { | ||
148 | + let name = $("#name").val(); | ||
149 | + if (!name) { | ||
150 | + toastr.error('请输入 标签名称。'); | ||
151 | + return; | ||
152 | + } | ||
153 | + // let semantics = $("#semantics").val(); | ||
154 | + // if (!semantics) { | ||
155 | + // toastr.error('请输入 标签语义。'); | ||
156 | + // return; | ||
157 | + // } | ||
158 | + | ||
159 | + let url = "/admin/categories/{{$id}}/labels"; | ||
160 | + $.ajax({ | ||
161 | + url: url, | ||
162 | + type: "POST", | ||
163 | + data: { | ||
164 | + label_id:"{{$label_id}}", | ||
165 | + name:name, | ||
166 | + can_multiple:$("input[name='can_multiple']:checked").val(), | ||
167 | + // semantics:semantics, | ||
168 | + // description:$("#description").val(), | ||
169 | + _token: LA.token, | ||
170 | + _method: 'POST' | ||
171 | + }, | ||
172 | + success: function (data) { | ||
173 | + if (data.code === 0) { | ||
174 | + toastr.success(data.message); | ||
175 | + window.parent.location.reload() | ||
176 | + } else { | ||
177 | + toastr.error(data.message); | ||
178 | + } | ||
179 | + }, | ||
180 | + complete:function(xhr,status) { | ||
181 | + // if (status == 'success') { | ||
182 | + // // _status = xhr.responseJSON.status; | ||
183 | + // | ||
184 | + // } | ||
185 | + } | ||
186 | + }); | ||
187 | + }) | ||
188 | + }) | ||
189 | + | ||
190 | + function LA() {} | ||
191 | + LA.token = "{{ csrf_token() }}"; | ||
192 | +</script> |
@@ -39,34 +39,34 @@ $api->version('v1', ['namespace' => 'App\Http\Api\V1\Controllers', 'middleware' | @@ -39,34 +39,34 @@ $api->version('v1', ['namespace' => 'App\Http\Api\V1\Controllers', 'middleware' | ||
39 | | 微信授权相关:包含小程序和公众号 | 39 | | 微信授权相关:包含小程序和公众号 |
40 | |------------------------------------------------------------------------------------------------------------------- | 40 | |------------------------------------------------------------------------------------------------------------------- |
41 | */ | 41 | */ |
42 | - $api->group(['prefix' => 'wechat'], function ($api) { | ||
43 | - $controller = 'WechatController'; | ||
44 | - $prefix = 'wechat'; | ||
45 | - $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid | ||
46 | - $api->any('mini-authorized-login', $controller .'@authorizeLoginMini')->name($prefix .'.authorize.Login');// 小程序 授权登录 | ||
47 | - $api->any('mini-phone', $controller .'@getMiniPhone')->name($prefix .'.phone');// 获取小程序用户手机号 | ||
48 | - | ||
49 | - | ||
50 | - $api->post('auth/token', $controller .'@authLogin')->name($prefix .'.login');// 微信授权登录:根据 method 判断登录方式 | ||
51 | - $api->post('auth/token/nickname', $controller .'@authLoginByNickname')->name($prefix .'.auth.nickname');// 小程序昵称授权 | ||
52 | - $api->post('auth/token/mobile', $controller .'@authLoginByMobile')->name($prefix .'.auth.mobile');// 小程序手机号授权 | ||
53 | - | ||
54 | - $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid | ||
55 | - $api->any('login-with-nickname', $controller .'@authorizeLoginByNickname')->name($prefix .'.authorize.Login');// 小程序 授权登录 | ||
56 | - $api->any('login-with-mobile', $controller .'@authorizeLoginByMobile')->name($prefix .'.phone');// 获取小程序用户手机号 | ||
57 | - | ||
58 | - $api->any('mini-user', $controller .'@getMiniUserInfo')->name($prefix .'.user.info'); // 获取微信用户信息 | ||
59 | - $api->any('mini-decrypt', $controller .'@decrypt')->name($prefix .'decrypt'); // 解密 | ||
60 | - $api->any('token', $controller .'@token')->name($prefix .'.token');// 验证 token | ||
61 | - $api->any('jssdk', $controller .'@jssdk')->name($prefix .'.jssdk');// 验证 token | ||
62 | - $api->any('auth', $controller.'@auth')->name($prefix.'.authorize'); // 授权 | ||
63 | - $api->get('openid', $controller .'@initOpenid')->name($prefix .'.openid')->middleware('check.xcx.user');// 验证 token | ||
64 | - $api->post('authorized-login', $controller .'@authorizeLogin')->name($prefix .'.authorize.Login')->middleware('check.xcx.user');// 授权登录 | ||
65 | - $api->post('openid', $controller .'@getOpenid')->name($prefix .'.user.openid')->middleware('check.xcx.user'); // 列表 | ||
66 | - $api->post('user', $controller .'@getWxUserInfo')->name($prefix .'.user.info'); // 列表 | ||
67 | - $api->post('server', $controller .'@server')->name($prefix .'.server'); | ||
68 | - $api->get('server', $controller .'@server')->name($prefix .'.server'); | ||
69 | - }); | 42 | +// $api->group(['prefix' => 'wechat'], function ($api) { |
43 | +// $controller = 'WechatController'; | ||
44 | +// $prefix = 'wechat'; | ||
45 | +// $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid | ||
46 | +// $api->any('mini-authorized-login', $controller .'@authorizeLoginMini')->name($prefix .'.authorize.Login');// 小程序 授权登录 | ||
47 | +// $api->any('mini-phone', $controller .'@getMiniPhone')->name($prefix .'.phone');// 获取小程序用户手机号 | ||
48 | +// | ||
49 | +// | ||
50 | +// $api->post('auth/token', $controller .'@authLogin')->name($prefix .'.login');// 微信授权登录:根据 method 判断登录方式 | ||
51 | +// $api->post('auth/token/nickname', $controller .'@authLoginByNickname')->name($prefix .'.auth.nickname');// 小程序昵称授权 | ||
52 | +// $api->post('auth/token/mobile', $controller .'@authLoginByMobile')->name($prefix .'.auth.mobile');// 小程序手机号授权 | ||
53 | +// | ||
54 | +// $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid | ||
55 | +// $api->any('login-with-nickname', $controller .'@authorizeLoginByNickname')->name($prefix .'.authorize.Login');// 小程序 授权登录 | ||
56 | +// $api->any('login-with-mobile', $controller .'@authorizeLoginByMobile')->name($prefix .'.phone');// 获取小程序用户手机号 | ||
57 | +// | ||
58 | +// $api->any('mini-user', $controller .'@getMiniUserInfo')->name($prefix .'.user.info'); // 获取微信用户信息 | ||
59 | +// $api->any('mini-decrypt', $controller .'@decrypt')->name($prefix .'decrypt'); // 解密 | ||
60 | +// $api->any('token', $controller .'@token')->name($prefix .'.token');// 验证 token | ||
61 | +// $api->any('jssdk', $controller .'@jssdk')->name($prefix .'.jssdk');// 验证 token | ||
62 | +// $api->any('auth', $controller.'@auth')->name($prefix.'.authorize'); // 授权 | ||
63 | +// $api->get('openid', $controller .'@initOpenid')->name($prefix .'.openid')->middleware('check.xcx.user');// 验证 token | ||
64 | +// $api->post('authorized-login', $controller .'@authorizeLogin')->name($prefix .'.authorize.Login')->middleware('check.xcx.user');// 授权登录 | ||
65 | +// $api->post('openid', $controller .'@getOpenid')->name($prefix .'.user.openid')->middleware('check.xcx.user'); // 列表 | ||
66 | +// $api->post('user', $controller .'@getWxUserInfo')->name($prefix .'.user.info'); // 列表 | ||
67 | +// $api->post('server', $controller .'@server')->name($prefix .'.server'); | ||
68 | +// $api->get('server', $controller .'@server')->name($prefix .'.server'); | ||
69 | +// }); | ||
70 | 70 | ||
71 | /* | 71 | /* |
72 | |------------------------------------------------------------------------------------------------------------------- | 72 | |------------------------------------------------------------------------------------------------------------------- |
-
请 注册 或 登录 后发表评论