<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Api\Controller; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Response; use ModStart\Core\Util\CRUDUtil; use ModStart\Module\ModuleBaseController; use Module\Member\Auth\MemberUser; use Module\Member\Support\MemberLoginCheck; use Module\Member\Util\MemberAddressUtil; class MemberAddressController extends ModuleBaseController implements MemberLoginCheck { public function all() { return Response::generateSuccessData(MemberAddressUtil::listUserAddresses(MemberUser::id())); } public function getDefault() { return Response::generateSuccessData(MemberAddressUtil::getDefault(MemberUser::id())); } public function edit() { goto tJnMS; moZN2: $cwaKT['isDefault'] = $tBuXm->getBoolean('isDefault'); goto Wx2VG; wrgNM: if ($StE5h) { $fk1iR = MemberAddressUtil::getUserAddress(MemberUser::id(), $StE5h); BizException::throwsIfEmpty('地址不存在', $fk1iR); } goto DfCV5; BfGBY: BizException::throwsIfEmpty('详细地址为空', $cwaKT['detail']); goto JjyXL; tgy_d: $cwaKT['area'] = $tBuXm->getTrimString('area'); goto QpAlK; B5IZm: $cwaKT['phone'] = $tBuXm->getTrimString('phone'); goto tgy_d; WlFzB: if ($fk1iR) { MemberAddressUtil::update($fk1iR['id'], $cwaKT); } else { $cwaKT['memberUserId'] = MemberUser::id(); MemberAddressUtil::insert($cwaKT); } goto Vc_32; HcBvZ: $StE5h = $tBuXm->getInteger('id'); goto nPU1W; Wx2VG: BizException::throwsIfEmpty('姓名为空', $cwaKT['name']); goto Qtyvm; navlc: BizException::throwsIfEmpty('地址为空', $cwaKT['area']); goto BfGBY; Qtyvm: BizException::throwsIfEmpty('手机为空', $cwaKT['phone']); goto navlc; jlNwa: $cwaKT['name'] = $tBuXm->getTrimString('name'); goto B5IZm; DfCV5: $cwaKT = array(); goto jlNwa; QpAlK: $cwaKT['detail'] = $tBuXm->getTrimString('detail'); goto moZN2; nPU1W: $fk1iR = null; goto wrgNM; Vc_32: return Response::generateSuccess(); goto OV8Nm; JjyXL: if ($cwaKT['isDefault']) { MemberAddressUtil::resetDefault(MemberUser::id()); } goto WlFzB; tJnMS: $tBuXm = InputPackage::buildFromInput(); goto HcBvZ; OV8Nm: } public function delete() { goto As0Ys; w1ZZn: $StE5h = $tBuXm->getInteger('id'); goto XPtUa; YI2YN: BizException::throwsIfEmpty('地址不存在', $fk1iR); goto aDa15; XPtUa: $fk1iR = MemberAddressUtil::getUserAddress(MemberUser::id(), $StE5h); goto YI2YN; As0Ys: $tBuXm = InputPackage::buildFromInput(); goto w1ZZn; aDa15: MemberAddressUtil::delete($fk1iR['id']); goto Kndhp; Kndhp: return Response::generateSuccess(); goto qiZX_; qiZX_: } }