Authored by 周少峰

add invoice

... ... @@ -359,8 +359,10 @@ class CartData
* @param string $cartType 购物车类型
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $invoiceType 发票类型 1:纸质,2:电子
* @param string $invoiceTitle 发票抬头
* @param int $invoiceContent 发票内容
* @param string $receiverMobile 发票接收人电话
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
... ... @@ -374,7 +376,7 @@ class CartData
* @param int $redEnvelopes 红包
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId,
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceType, $invoiceTitle, $invoiceContent, $receiverMobile,
$paymentId, $paymentType, $remark,$couponCode,$promotionCode, $yohoCoin, $isPreContact, $isPrintPrice, $unionKey,$userAgent, $redEnvelopes)
{
$param = Yohobuy::param();
... ... @@ -387,11 +389,18 @@ class CartData
$param['delivery_time'] = $deliveryTime;
$param['delivery_way'] = $deliveryWay;
$param['uid'] = $uid;
if (!empty($invoiceType)) {
$param['invoices_type'] = $invoiceType;
}
if (!empty($invoiceTitle)) {
$param['invoices_title'] = $invoiceTitle;
}
if (!empty($invoiceId)) {
$param['invoices_type_id'] = $invoiceId;
if (!empty($invoiceContent)) {
$param['invoice_content'] = $invoiceContent;
}
if (!empty($receiverMobile)) {
$param['receiverMobile'] = $receiverMobile;
}
if (!empty($redEnvelopes)) {
$param['use_red_envelopes'] = $redEnvelopes;
... ... @@ -420,7 +429,6 @@ class CartData
}
$param['remark'] = $remark;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, false, false, 10, $userAgent);
}
... ... @@ -522,5 +530,5 @@ class CartData
$param['payment'] = $payment;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
}
... ...
... ... @@ -226,6 +226,16 @@ class OrderModel
}
$detail['orderBalance'][] = array('promotion' => '实际应支付', 'account' => $orderDetail['amount']);
}
//发票
if (isset($orderDetail['invoice']) && $orderDetail['invoice']) {
$detail['invoiceMode'] = true;
$detail['invoiceType'] = $orderDetail['invoice']['type'];
$detail['pdfUrl'] = $orderDetail['invoice']['pdfUrl'];
$detail['title'] = $orderDetail['invoice']['title'];
$detail['contentValue'] = $orderDetail['invoice']['contentValue'];
$detail['showInvoice'] = $orderDetail['invoice']['showInvoice'];
}
$detail['yoho_give_coin'] = $orderDetail['yoho_give_coin'];
$detail['yohoCoinUrl'] = Helpers::url('/help', array('category_id' => 87)); //什么是yoho币介绍
$detail['remark'] = $orderDetail['remark'];
... ...
... ... @@ -579,6 +579,9 @@ class CartModel
do {
/* 调接口订单确认接口 */
$pay = CartData::cartPay($uid, $cartType);
//获取用户手机号码用于发票接收人
$userInfo = UserData::getUserInfo($uid);
if (!$pay || empty($pay['data']['goods_list'])) {
break;
}
... ... @@ -695,14 +698,14 @@ class CartModel
}
}
/* 发票类型 */
if (!empty($pay['data']['invoices']['invoices_type_list'])) {
$build = array();
foreach ($pay['data']['invoices']['invoices_type_list'] as $value) {
$build['id'] = $value['invoices_type_id'];
$build['name'] = $value['invoices_type_name'];
$result['piaoTypes'][] = $build;
/* 发票内容 */
if (!empty($pay['data']['invoices']['invoiceContentList'])) {
foreach ($pay['data']['invoices']['invoiceContentList'] as $value) {
$result['piaoTypes'][$value['invoices_type_id']]['id'] = $value['invoices_type_id'];
$result['piaoTypes'][$value['invoices_type_id']]['name'] = $value['invoices_type_name'];
}
$result['receiverMobile'] = isset($userInfo['data']['mobile']) && $userInfo['data']['mobile'] ? $userInfo['data']['mobile'] : '';
$result['invoiceUrl'] = 'http://www.yohobuy.com/help?category_id=99';
}
/* 需购买的商品 */
... ... @@ -895,7 +898,7 @@ class CartModel
* @param int $redEnvelopes 红包
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode,$promotionCode, $yohoCoin, $isPreContact, $isPrintPrice, $redEnvelopes)
public static function orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceType, $invoiceTitle, $invoiceContent, $receiverMobile, $paymentId, $paymentType, $remark, $couponCode,$promotionCode, $yohoCoin, $isPreContact, $isPrintPrice, $redEnvelopes)
{
$result = array('code' => 400, 'message' => self::ERROR_400_MESSAGE);
... ... @@ -936,7 +939,7 @@ class CartModel
$userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null;
}
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode,$promotionCode,$yohoCoin, $isPreContact, $isPrintPrice,$unionKey,$userAgent, $redEnvelopes);
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceType, $invoiceTitle, $invoiceContent, $receiverMobile, $paymentId, $paymentType, $remark, $couponCode,$promotionCode,$yohoCoin, $isPreContact, $isPrintPrice,$unionKey,$userAgent, $redEnvelopes);
if ($orderSubRes && isset($orderSubRes['code'])) {
$result = $orderSubRes;
}
... ...
... ... @@ -439,8 +439,11 @@ class IndexController extends WebAction
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTimeId = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWayId = $this->post('deliveryWayId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceTitle', null); // 发票抬头
$invoiceId = $this->post('invoiceId', null); // 发票类型
$invoiceType = $this->post('invoiceType', null); // 发票类型:纸质 1 ,电子 2
$invoiceTitle = $this->post('invoiceTitle', '个人'); // 发票抬头
$invoiceContent = $this->post('invoiceContent', null); // 发票内容
$receiverMobile = $this->post('receiverMobile', null); // 接收人电话
$paymentId = $this->post('paymentId', 15); // 支付ID
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('remark', ''); // 备注信息
... ... @@ -450,9 +453,8 @@ class IndexController extends WebAction
$isPreContact = $this->post('isPreContact', false); // 送货前是否联系
$isPrintPrice = $this->post('isPrintPrice', true); // 是否打印价格
$redEnvelopes = $this->post('redEnvelopes', null);
// 调用下单接口
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId,
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceType, $invoiceTitle, $invoiceContent, $receiverMobile,
$paymentId, $paymentType, $remark, $couponCode, $promotionCode, $yohoCoin, $isPreContact, $isPrintPrice, $redEnvelopes);
// 判断是否下单成功
if (empty($result['data']['order_code'])) {
... ...
... ... @@ -122,6 +122,12 @@ class OrdersController extends WebAction
'operation' => $detail['operation'],
'totalYoho' => $detail['yoho_give_coin'],
'editInfo' => $detail['editInfo'],
//发票信息
'invoiceMode' => $detail['invoiceMode'],
'invoiceType' => $detail['invoiceType'] === 2 ? '电子发票' : '纸质发票',
'pdfUrl' => $detail['showInvoice'] && $detail['pdfUrl'] ? $detail['pdfUrl'] : '',
'title' => $detail['title'],
'contentValue' => $detail['contentValue'] ? $detail['contentValue'] : '个人',
);
if (isset($detail['noramlPayMode'])) {
$data['orderInfo'] = $detail['orderInfo'];
... ...