Authored by Rock Zhang

添加地址管理修改,删除等接口

@@ -285,6 +285,24 @@ class UserData @@ -285,6 +285,24 @@ class UserData
285 } 285 }
286 286
287 /** 287 /**
  288 + * 删除地址
  289 + *
  290 + * @param int $uid 用户ID
  291 + * @param int $id 地址唯一标识符id
  292 + * @return array 接口返回的数据
  293 + */
  294 + public static function deleteAddress($uid, $id)
  295 + {
  296 + $param = Yohobuy::param();
  297 + $param['id'] = $id;
  298 + $param['method'] = 'app.address.del';
  299 + $param['uid'] = $uid;
  300 + $param['client_secret'] = Sign::getSign($param);
  301 +
  302 + return Yohobuy::get(Yohobuy::API_URL, $param);
  303 + }
  304 +
  305 + /**
288 * 意见反馈数据 306 * 意见反馈数据
289 * 307 *
290 * @param string $udid 客户端唯一标识 308 * @param string $udid 客户端唯一标识
@@ -122,7 +122,7 @@ class HomeController extends AbstractAction @@ -122,7 +122,7 @@ class HomeController extends AbstractAction
122 $this->setNavHeader('YOHO币', true, false); 122 $this->setNavHeader('YOHO币', true, false);
123 123
124 // $uid = $this->getUid(); 124 // $uid = $this->getUid();
125 - $uid = 967016; 125 + $uid = 8826435;
126 $currency = \Index\UserModel::getYohoCoinData($uid); 126 $currency = \Index\UserModel::getYohoCoinData($uid);
127 127
128 $currency['pageFooter'] = true; 128 $currency['pageFooter'] = true;
@@ -154,7 +154,7 @@ class HomeController extends AbstractAction @@ -154,7 +154,7 @@ class HomeController extends AbstractAction
154 $page = $this->get('page', 0); 154 $page = $this->get('page', 0);
155 $size = $this->get('size', 10); 155 $size = $this->get('size', 10);
156 156
157 - $uid = 967016; 157 + $uid = 8826435;
158 $messages = \Index\UserModel::getMessageData($uid, $page, $size); 158 $messages = \Index\UserModel::getMessageData($uid, $page, $size);
159 159
160 print_r($messages); 160 print_r($messages);
@@ -169,7 +169,7 @@ class HomeController extends AbstractAction @@ -169,7 +169,7 @@ class HomeController extends AbstractAction
169 $this->setNavHeader('地址管理', true, SITE_MAIN); 169 $this->setNavHeader('地址管理', true, SITE_MAIN);
170 170
171 // $uid = $this->getUid(); 171 // $uid = $this->getUid();
172 - $uid = 967016; 172 + $uid = 8826435;
173 173
174 $address = \Index\UserModel::getAddressData($uid); 174 $address = \Index\UserModel::getAddressData($uid);
175 $addressList = \Index\UserModel::getAddressListData($uid); 175 $addressList = \Index\UserModel::getAddressListData($uid);
@@ -192,7 +192,7 @@ class HomeController extends AbstractAction @@ -192,7 +192,7 @@ class HomeController extends AbstractAction
192 192
193 if ($this->isAjax()) { 193 if ($this->isAjax()) {
194 // $uid = $this->getUid(); 194 // $uid = $this->getUid();
195 - $uid = 967016; 195 + $uid = 8826435;
196 $address = $this->post('address', ''); 196 $address = $this->post('address', '');
197 $area_code = $this->post('area_code', ''); 197 $area_code = $this->post('area_code', '');
198 $consignee = $this->post('consignee', ''); 198 $consignee = $this->post('consignee', '');
@@ -219,7 +219,7 @@ class HomeController extends AbstractAction @@ -219,7 +219,7 @@ class HomeController extends AbstractAction
219 219
220 if ($this->isAjax()) { 220 if ($this->isAjax()) {
221 // $uid = $this->getUid(); 221 // $uid = $this->getUid();
222 - $uid = 967016; 222 + $uid = 8826435;
223 $id = $this->post('id', ''); 223 $id = $this->post('id', '');
224 224
225 $result = \Index\UserModel::setDefaultAddress($uid, $id); 225 $result = \Index\UserModel::setDefaultAddress($uid, $id);
@@ -232,6 +232,27 @@ class HomeController extends AbstractAction @@ -232,6 +232,27 @@ class HomeController extends AbstractAction
232 } 232 }
233 } 233 }
234 234
  235 + /**
  236 + * 删除地址
  237 + */
  238 + public function addressDelAction() {
  239 + $result = array();
  240 +
  241 + if ($this->isAjax()) {
  242 + // $uid = $this->getUid();
  243 + $uid = 8826435;
  244 + $id = $this->post('id', '');
  245 +
  246 + $result = \Index\UserModel::deleteAddress($uid, $id);
  247 + }
  248 +
  249 + if (empty($result)) {
  250 + echo ' ';
  251 + } else {
  252 + $this->echoJson($result);
  253 + }
  254 + }
  255 +
235 //在线客服 256 //在线客服
236 public function onlineServiceAction() { 257 public function onlineServiceAction() {
237 // 设置网站标题 258 // 设置网站标题
@@ -59,7 +59,11 @@ class UserModel @@ -59,7 +59,11 @@ class UserModel
59 foreach ($infoNumData['data'] as &$val) { 59 foreach ($infoNumData['data'] as &$val) {
60 empty($val) && $val = 0; 60 empty($val) && $val = 0;
61 } 61 }
  62 +
62 $result = $infoNumData['data']; 63 $result = $infoNumData['data'];
  64 +
  65 + // 默认没有返回用户地址的数据,添加这块儿数据
  66 + $result['address_num'] = count(self::getAddressData($uid));
63 } 67 }
64 68
65 return $result; 69 return $result;
@@ -384,6 +388,27 @@ class UserModel @@ -384,6 +388,27 @@ class UserModel
384 } 388 }
385 389
386 /** 390 /**
  391 + * 删除地址
  392 + *
  393 + * @param int $uid 用户ID
  394 + * @param int $id 地址唯一标识符id
  395 + * @return array|mixed 处理之后的返回数据
  396 + */
  397 + public static function deleteAddress($uid, $id)
  398 + {
  399 + $result = array('code' => 400, 'message' => '错误');
  400 +
  401 + // 调用接口删除地址
  402 + $address = UserData::deleteAddress($uid, $id);
  403 + // 处理返回结果
  404 + if ($address && isset($address['code'])) {
  405 + $result = $address;
  406 + }
  407 +
  408 + return $result;
  409 + }
  410 +
  411 + /**
387 * 处理意见反馈数据 412 * 处理意见反馈数据
388 * 413 *
389 * @param string $udid 客户端唯一标识 414 * @param string $udid 客户端唯一标识