Authored by cailing

订单详情页——地址修改,取消原因

... ... @@ -35,7 +35,7 @@ class OrderData
* 取消订单
*/
public static function cancelOrderData($orderCode, $uid, $gender, $channel)
public static function cancelOrderData($orderCode, $uid, $gender, $channel, $resonsid = false, $resons = false)
{
//构建必传参数
$param = Yohobuy::param();
... ... @@ -43,6 +43,8 @@ class OrderData
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $channel;
// $param['resonsid'] = $resonsid;
// $param['resons'] = $resons;
$param['method'] = 'app.SpaceOrders.close';
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
... ... @@ -110,7 +112,7 @@ class OrderData
/*
* 支付页面的资源位
*/
public static function paymentData($gender, $yh_channel, $code)
{
//构建必传参数
... ... @@ -140,7 +142,7 @@ class OrderData
//调用接口获得数据
return Yohobuy::get(Yohobuy::SERVICE_URL . '/operations/api/v5/resource/get', $param);
}
/**
* 更新订单的支付方式
*
... ... @@ -158,9 +160,43 @@ class OrderData
$param['payment'] = $payment;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
// 调用接口获得数据
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 订单详情页——地址修改
* @param type $order_code
* @param type $address_id
* @return type
*/
public static function updateDeliveryAddress($order_code, $address_id)
{
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.SpaceOrders.updateDeliveryAddress';
$param['order_code'] = $order_code;
$param['address_id'] = $address_id;
$param['client_secret'] = Sign::getSign($param);
// 调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 取消订单原因列表
* @return type
*/
public static function closeReasons()
{
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.SpaceOrders.closeReasons';
$param['client_secret'] = Sign::getSign($param);
// 调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -16,8 +16,8 @@ require('../common');
$('.address-item').on('touchend', function() {
selectId = $(this).data('addressId');
if ($modifyAdd.data('rel') === 'true') {
console.log($modifyAdd.data('rel'));
if ($modifyAdd.data('rel') === true) {
$confimMod.find('.content').text('关联订单的收货地址将会一起修改且不可修改第二次,请确认是否修改?');
$confimMod.fadeIn();
} else {
... ... @@ -36,7 +36,7 @@ $confimMod.on('touchend', '.cancel', function(e) {
}).on('touchend', '.confim', function() {
$.ajax({
method: 'POST',
url: '',
url: '/home/chooseAddress',
data: {
id: selectId,
orderCode: orderCode
... ... @@ -48,7 +48,7 @@ $confimMod.on('touchend', '.cancel', function(e) {
if (res.code !== 200) {
tip.show(res.message || '网络出了点问题~');
} else {
window.location.reload();
window.location.href = '/home/orderdetail?orderCode=' + orderCode;
}
}).fail(function() {
tip.show('网络出了点问题~');
... ...
... ... @@ -92,6 +92,6 @@ optHammer.on('tap', function(e) {
if ($ownerInfo.data('changeable') === true) {
$ownerInfo.find('.rest').show();
$ownerInfo.on('touchend', function() {
location.href = '/home/addressModify';
location.href = $ownerInfo.data('url');
});
}
... ...
{{> layout/header}}
<div class="my-address-page modify-address-page select-address-page yoho-page">
<div class="page-wrap clearfix modifyAdd" data-rel="{{hasRelations}}" data-order-code="{{orderCode}}">
<div class="page-wrap clearfix modifyAdd" data-rel="{{relation}}" data-order-code="{{orderCode}}">
{{# address}}
<div class="address-item" data-address-id="{{address_id}}" >
<span class="name">{{consignee}}</span>
... ...
... ... @@ -2,7 +2,7 @@
<div class="order-detail-page yoho-page">
{{# orderDetail}}
<div id="order-detail" data-id="{{orderNum}}">
<section class="owner-info block" data-changeable="{{changeable}}">
<section class="owner-info block" data-changeable="{{changeable}}" data-url="{{url}}">
<span class="iconfont">&#xe631;</span>
<div class="beside-icon">
... ...
... ... @@ -455,31 +455,6 @@ class HomeController extends AbstractAction
}
/**
* 地址修改
*/
public function addressModifyAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('地址修改');
$this->setNavHeader('地址修改', Helpers::url('/home'), false);
$uid = $this->_uid;
$address = UserModel::getAddressData($uid);
//以下为测试数据
$this->_view->display('address_modify', array(
'addressModifyPage' => true,
'pageFooter' => true,
'address' => $address,
'showAddBtn' => (count($address) <= 5),
));
}
/**
*
* 地址编辑或添加页面
*/
... ... @@ -862,11 +837,13 @@ class HomeController extends AbstractAction
//传入orderCode取消订单
$orderCode = $this->get('id');
$resons = $this->get('resons', ''); //取消订单原因
$resonsid = $this->get('resonsid', ''); //取消原因id
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelByCookie();
$uid = $this->getUid(true);
//调用取消订单接口,返回订单取消状态
$data = OrderData::cancelOrderData($orderCode, $uid, $gender, $channel);
$data = OrderData::cancelOrderData($orderCode, $uid, $gender, $channel, $resonsid, $resons);
//将取消状态返回至浏览器
if (!$data) {
$this->echoJson(array('message' => '取消订单失败'));
... ... @@ -1095,6 +1072,36 @@ class HomeController extends AbstractAction
}
/**
* 订单详情页——地址列表
*/
public function addressModifyAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('地址修改');
$this->setNavHeader('地址修改', Helpers::url('/home'), false);
$uid = $this->_uid;
$address = UserModel::getAddressData($uid);
$orderCode = $this->get('orderCode', '');
$relation = $this->get('relation', '');
//以下为测试数据
$this->_view->display('address_modify', array(
'addressModifyPage' => true,
'pageFooter' => true,
'address' => $address,
'showAddBtn' => (count($address) <= 5),
'orderCode' => $orderCode,
'relation' => $relation
));
}
/**
* 订单详情页地址修改
*/
public function chooseAddressAction()
... ... @@ -1107,13 +1114,13 @@ class HomeController extends AbstractAction
break;
}
//获取相关参数
$uid = $this->getUid(true);
$id = $this->get('id', '');
if (!$uid || !$id) {
$order_code = $this->get('order_code', ''); //订单号
$address_id = $this->get('address_id', ''); //地址id
if (!$order_code || !$order_code) {
$result = array('code' => 400, 'message' => '缺失必填项', 'data' => '');
break;
}
$result = AddressData::deleteAddress($uid, $id);
$result = OrderData::updateDeliveryAddress($order_code, $address_id);
if (!isset($result['code'])) {
break;
}
... ...
... ... @@ -235,15 +235,15 @@ class OrderModel
$result['changeable'] = 'true';
}
//判断是否有关联订单
if (isset($orderDetail['data']['relate_order_code']) && $orderDetail['data']['relate_order_code'] == 'Y') {
$result['relation'] = 'true';
}
// $result['relation'] =$orderDetail['data']['relate_order_code'] == 'Y' ? 'true' : 'false';
$result['relation'] = 'true';
//测试
$result['changeable'] = 'true';
}
$result['url'] = Helpers::url('/home/addressModify', array('orderCode' => $orderCode, 'relation' => $result['relation']));
$result['url'] = Helpers::url('/home/addressModify', array('orderCode' => $orderCode, 'relation' => $result['relation'] ));
//取消订单原因列表
$reson = OrderData::closeReasons();
return $result;
}
... ...