Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jwhx
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sugar
jwhx
Commits
50bfedd5
Commit
50bfedd5
authored
Nov 19, 2024
by
董先生
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
置换订单收集
parent
b1856cc7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
0 deletions
+112
-0
modules/Order/app/Controllers/Api/Exchange.php
modules/Order/app/Controllers/Api/Exchange.php
+35
-0
modules/Order/app/Models/Exchange.php
modules/Order/app/Models/Exchange.php
+26
-0
modules/Order/app/Services/ExchangeService.php
modules/Order/app/Services/ExchangeService.php
+48
-0
modules/Order/routes/api.php
modules/Order/routes/api.php
+3
-0
No files found.
modules/Order/app/Controllers/Api/Exchange.php
0 → 100644
View file @
50bfedd5
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace
Modules\Order\Controllers\Api
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\BaseController
;
use
Modules\Order\Services\ExchangeService
;
class
Exchange
extends
BaseController
{
/**
* @title 添加置换收集订单记录
*
* @param Request $request
* @param ExchangeService $service
* @return void
*/
public
function
add
(
Request
$request
,
ExchangeService
$service
){
try
{
$this
->
data
[
'data'
]
=
$service
->
create
(
$request
);
$this
->
data
[
'message'
]
=
'添加成功,请耐心等候'
;
}
catch
(
\Throwable
$th
)
{
$this
->
data
[
'code'
]
=
0
;
$this
->
data
[
'message'
]
=
$th
->
getMessage
();
}
return
response
()
->
json
(
$this
->
data
);
}
}
\ No newline at end of file
modules/Order/app/Models/Exchange.php
0 → 100644
View file @
50bfedd5
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace
Modules\Order\Models
;
use
App\Models\BaseModel
;
class
Exchange
extends
BaseModel
{
protected
$table
=
'exchange_order'
;
protected
$fillable
=
[
'uid'
,
'name'
,
'mobile'
,
'status'
,
'createtime'
,
'address'
,
'remark'
];
// protected $hidden = ['deleted'];
protected
function
casts
()
:
array
{
return
[
'status'
=>
'integer'
,
'createtime'
=>
'datetime:Y-m-d H:i:s'
,
];
}
}
modules/Order/app/Services/ExchangeService.php
0 → 100644
View file @
50bfedd5
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace
Modules\Order\Services
;
use
Modules\Order\Models\Exchange
;
class
ExchangeService
{
/**
* @title 添加置换收集订单
*
* @param [type] $request
* @return void
*/
public
function
create
(
$request
)
{
$request
->
validate
([
'name'
=>
'required'
,
'address'
=>
'required'
,
'mobile'
=>
'require|regex:^1[3-9]\d{9}$'
,
],
[
'name.required'
=>
'请填写姓名'
,
'mobile.required'
=>
'请填写手机号码'
,
'mobile.regex'
=>
'手机号格式不正确'
,
'address.required'
=>
'请填写所在地址'
]);
$exchange
=
new
Exchange
();
$info
=
Exchange
::
where
([
'mobile'
=>
$request
->
post
(
'mobile'
)])
->
first
();
if
(
$info
){
throw
new
\Exception
(
"此号码已填写过"
,
0
);
}
$exchange
->
uid
=
auth
(
'api'
)
->
user
()[
'uid'
];
$exchange
->
name
=
$request
->
post
(
'name'
);
$exchange
->
mobile
=
$request
->
post
(
'mobile'
);
$exchange
->
status
=
1
;
$exchange
->
createtime
=
time
();
$exchange
->
address
=
$request
->
post
(
'address'
);
$exchange
->
remark
=
$request
->
post
(
'remark'
)
??
''
;
$exchange
->
save
();
return
$exchange
;
}
}
\ No newline at end of file
modules/Order/routes/api.php
View file @
50bfedd5
...
@@ -38,4 +38,7 @@ Route::name('order.')->prefix('order')->middleware(['auth.check:api'])->group(fu
...
@@ -38,4 +38,7 @@ Route::name('order.')->prefix('order')->middleware(['auth.check:api'])->group(fu
Route
::
put
(
'/edit'
,
'edit'
)
->
name
(
'edit'
);
Route
::
put
(
'/edit'
,
'edit'
)
->
name
(
'edit'
);
Route
::
delete
(
'/delete'
,
'delete'
)
->
name
(
'delete'
);
Route
::
delete
(
'/delete'
,
'delete'
)
->
name
(
'delete'
);
});
});
Route
::
controller
(
Modules\Order\Controllers\Api\Exchange
::
class
)
->
prefix
(
'exchange'
)
->
name
(
'exchange.'
)
->
group
(
function
()
{
Route
::
post
(
'/add'
,
'add'
)
->
name
(
'add'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment