feat: 增加地址API功能
This commit is contained in:
parent
177d9576c7
commit
97a7a830c3
@ -67,8 +67,14 @@ class AddressLogic extends BaseLogic
|
||||
'phone' => $params['phone'],
|
||||
'detail' => $params['detail'],
|
||||
'is_default' => $params['is_default'],
|
||||
'province' => $params['province'],
|
||||
'city' => $params['city'],
|
||||
'area' => $params['area'],
|
||||
'street' => $params['street'],
|
||||
'village' => $params['village'],
|
||||
'brigade' => $params['brigade'],
|
||||
];
|
||||
UserAddress::where('uid', $params['uid'])->where('id', $params['address_id'])->update($data);
|
||||
UserAddress::where('uid', $params['uid'])->where('id', $params['id'])->update($data);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -93,7 +99,7 @@ class AddressLogic extends BaseLogic
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取购物车表详情
|
||||
* @notes 获取地址详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
@ -101,6 +107,6 @@ class AddressLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserAddress::field('id address_id,real_name,phone,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray();
|
||||
return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where($params)->findOrEmpty()->toArray();
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class UserAddressValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['real_name','phone','detail','address_id']);
|
||||
return $this->only(['real_name','phone','detail','id']);
|
||||
}
|
||||
|
||||
|
||||
|
49
app/store/controller/user/AddressController.php
Normal file
49
app/store/controller/user/AddressController.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\user;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\user\UserAddressList;
|
||||
use app\api\logic\user\AddressLogic;
|
||||
use app\api\validate\UserAddressValidate;
|
||||
|
||||
|
||||
class AddressController extends BaseApiController
|
||||
{
|
||||
public function lists(){
|
||||
return $this->dataLists(new UserAddressList());
|
||||
}
|
||||
/**
|
||||
* @notes 编辑地址
|
||||
* @return \support\Response
|
||||
* @author likeadmin
|
||||
* @date 2024/4/24 10:37
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new UserAddressValidate())->post()->goCheck('edit');
|
||||
if(AddressLogic::edit($params)){
|
||||
return $this->success('编辑成功');
|
||||
}else{
|
||||
return $this->fail(AddressLogic::getError());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 获取地址详情
|
||||
* @return \support\Response
|
||||
* @author likeadmin
|
||||
* @date 2024/4/24 10:37
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$uid = $this->request->get('uid');
|
||||
if($id){
|
||||
$params = ['id' => $id];
|
||||
}
|
||||
if($uid){
|
||||
$params = ['uid' => $uid];
|
||||
}
|
||||
return $this->success('获取成功',AddressLogic::detail($params));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user