Authored by cailing

电子发票代码返回

... ... @@ -4,6 +4,7 @@ namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
use Plugin\Helpers;
/**
* 购物车的数据模型
... ... @@ -365,7 +366,8 @@ class CartData
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param array $invoices 发票参数数组
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
... ... @@ -381,28 +383,22 @@ class CartData
$param = Yohobuy::param();
$param['debug'] = 'Y';
$param['client_type'] = 'h5'; // 需要ERP统计WAP的下单量
if(Helpers::is_weixin()) {
$param['client_type'] = 'wechat';
}
$param['private_key'] = Yohobuy::$privateKeyList['android']; // H5默认使用Android的私钥
$param['method'] = 'app.Shopping.submit';
$param['address_id'] = $addressId;
$param['cart_type'] = $cartType;
$param['delivery_time'] = $deliveryTime;
$param['delivery_way'] = $deliveryWay;
if (!empty($invoices['invoices_type_id'])) {
//发票内容id--图书:1
$param['invoice_content'] = $invoices['invoices_type_id'];
}
if (!empty($invoices['invoices_type'])) {
//数字类型 发票类型 /**纸质 1 ,电子 2 */
$param['invoices_type'] = $invoices['invoices_type'];
if (!empty($invoiceTitle)) {
$param['invoices_title'] = $invoiceTitle;
}
if (!empty($invoices['receiverMobile'])) {
//发票人手机
$param['receiverMobile'] = $invoices['receiverMobile'];
}
if (!empty($invoices['invoices_title'])) {
//发票抬头 OR 填写单位名称,这二个是一个意思,只是叫法不一样
$param['invoices_title'] = $invoices['invoices_title'];
if (!empty($invoiceId)) {
$param['invoices_type_id'] = $invoiceId;
}
$param['payment_id'] = $paymentId;
$param['payment_type'] = $paymentType;
$param['remark'] = $remark;
... ...
... ... @@ -829,6 +829,40 @@ class HomeController extends AbstractAction
//渲染模板
$this->_view->display('order-content', $order);
}
/**
* 我的订单——再次购买
*/
public function reAddAction()
{
$result = array('code' => 401, 'message' => '商品加入购物车失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取相关参数
$uid = $this->getUid(true);
$orderCode = $this->get('orderCode', '');
if (!$uid || !$orderCode) {
$result = array('code' => 400, 'message' => '缺失参数', 'data' => '');
break;
}
$reAddData = OrderData::reAddData($uid, $orderCode);
if(!isset($reAddData['code']) || $reAddData['code'] != 200){
break;
}
$result = array('code' => 200, 'message' => '商品已重新加入购物车', 'data' => $reAddData['data']);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
/*
* 我的订单-取消订单
... ... @@ -1022,7 +1056,6 @@ class HomeController extends AbstractAction
$input->SetTotal_fee($totalFee);
$input->SetTime_start(date("YmdHis", (int) $orderDetail['data']['create_time']));
$input->SetTime_expire(date("YmdHis", (int) $orderDetail['data']['create_time'] + 7200));
$input->SetNotify_url(WxPayConfig::NOTIFY_URL);
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
... ... @@ -1063,6 +1096,8 @@ class HomeController extends AbstractAction
/* 判断订单信息是否存在 */
$orderDetail = OrderModel::orderDetail($orderCode, $this->_uid, $this->_usession);
// $readd = OrderData::reAddData($this->_uid, 1611143210);
// print_r($readd);
if (empty($orderDetail)) {
$this->error();
}
... ... @@ -1073,7 +1108,6 @@ class HomeController extends AbstractAction
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'invoice' => empty($orderDetail['invoice']) ? array() : $orderDetail['invoice'],
'serviceUrl' => 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=',
'orderDetail' => $orderDetail,
'orderCode' => $orderCode,
... ...
... ... @@ -240,37 +240,6 @@ class OrderModel
$result['isJit'] = true;
$result['jitDetailUrl'] = Helpers::url('/cart/index/jitDetail', array('orderCode' => $orderCode, 'sessionKey' => $sessionKey));
}
$result['invoice'] = array();
//电子发票
do{
if(empty($orderDetail['data']['invoice']) || !isset($orderDetail['data']['invoice'])){
break;
}
//判断是否显示电子发票相关信息
if(isset($orderDetail['data']['invoice']['type']) == false && empty($orderDetail['data']['invoice']['type'])){
break;
}
//判断是否显示电子发票下载地址
$result['invoice'] = $orderDetail['data']['invoice'];
//纸质 1,电子 2
$result['invoice']['type'] = $result['invoice']['type'] * 1 === 2 ? true : false;//发票类型
$result['invoice']['title'] = $result['invoice']['title'];//发票抬头
$result['invoice']['contentValue'] = $result['invoice']['contentValue'];//发票内容
$result['invoice']['mobilePhone'] = $result['invoice']['mobilePhone'];//联系电话
//电子发票下载链接
if($orderDetail['data']['invoice']['showInvoice'] == true && isset($orderDetail['data']['invoice']['pdfUrl'])){
$result['invoice']['pdfUrl'] = $result['invoice']['pdfUrl'];
}
}
while(false);
// $result['invoice'] = array(
// 'type' => true,//-- 纸质 false,电子 true
// 'title' => '发票抬头',// --发票抬头
// 'contentValue' => '服饰',//-- 发票内容
// 'mobilePhone' => '13651898702',//--电话
// 'pdfUrl' => 'http://redmine.yoho.cn/attachments/download/2732/%E7%94%B5%E5%AD%90%E5%8F%91%E7%A5%A8-wap%E7%AB%AF.pdf',//--pdf下载地址
// );
}
//取消订单原因列表
$resons = OrderData::closeReasons();
... ...
... ... @@ -571,11 +571,14 @@ class CartModel
// 发票有关数据
if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) {
foreach ($payReturn['invoices']['invoiceContentList'] as $inv) {
$result['invoice'][] = array(
'id' => $inv['invoices_type_id'],
'name' => $inv['invoices_type_name'],
);
$one = array();
foreach ($payReturn['invoices']['invoices_type_list'] as $inv) {
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
isset($orderInfo['invoiceType']) && $one['id'] == $orderInfo['invoiceType'] && $one['isSelected'] = true;
$result['invoice'][] = $one;
}
// 发票信息需要记录
... ... @@ -591,11 +594,17 @@ class CartModel
// 优惠券数据
$coupons = array(
'couponName' => '',
'isCoupon' => false,
'count' => self::getValidCouponCount($uid)
);
if (isset($orderCompute['coupon_amount']) && (!empty($orderCompute['coupon_amount']) || ($orderCompute['coupon_amount'] === 0 && $orderCompute['shipping_cost'] === 0))) {
$coupons['couponName'] = $orderInfo['couponName'];
}
//选中已使用的优惠劵,则剩余多少张优惠劵,不提示
if (empty($coupons['couponName']) || $coupons['count'] === 0) {
$coupons['isCoupon'] = true;
}
$result['coupon'] = $coupons;
}
while (false);
... ... @@ -736,7 +745,8 @@ class CartModel
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param array $invoices 发票参数数组
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
... ... @@ -747,7 +757,7 @@ class CartModel
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio = '', $userAgent = null)
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio = '', $userAgent = null)
{
$result = array('code' => 400, 'message' => '出错啦');
... ... @@ -765,7 +775,7 @@ class CartModel
$result['message'] = '请选择配送方式';
}
else {
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio, $userAgent);
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio, $userAgent);
UdpLog::info('【结算信息】接口返回','orderSubRes'.json_encode($orderSubRes));
if ($orderSubRes && isset($orderSubRes['code'])) {
$result = $orderSubRes;
... ...
... ... @@ -5,8 +5,9 @@ use Hood\Core\Security\AuthCode;
use Index\CartModel;
use Index\UserModel;
use Plugin\Helpers;
use Plugin\UnionTrans;
use Home\OrderModel;
use Plugin\UdpLog;
use LibModels\Wap\Home\UserData;
/**
* 购物车相关的控制器
... ... @@ -301,12 +302,13 @@ class IndexController extends AbstractAction
// 返回地址
$returnUrl = Helpers::url('/cart/index/index');
$cartType = $this->get('cartType', '');
$cartType = $this->get('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$orderInfo = array();
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$cartType = $orderInfo['cartType'];
//如果为空,获取默认
$cartType = empty($orderInfo['cartType']) ? $cartType : $orderInfo['cartType'];
}
// 如果传递了code, sku,skn,buy_number就代表是限购商品
... ... @@ -331,13 +333,11 @@ class IndexController extends AbstractAction
$this->echoJson($order);
return;
}
$userData = UserData::userData($uid);
$mobile = empty($userData['data']) || empty($userData['data']['mobile']) ? '' : $userData['data']['mobile']; //发票人手机
$data = array(
'orderEnsurePage' => true,
'isOrdinaryCart' => ($cartType !== 'advance'),
'orderEnsure' => $order,
'userMobile' => $mobile
'orderEnsure' => $order
);
$this->setTitle('确认订单');
... ... @@ -347,108 +347,6 @@ class IndexController extends AbstractAction
}
/**
* 发票信息
*/
public function invoiceInfoAction()
{
$uid = $this->getUid();
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
}
$cookieData = $this->getCookie('order-info', null); //从缓存中获取电子发票信息
$userData = UserData::userData($uid);
$userMobile = empty($userData['data']) || empty($userData['data']['mobile']) ? '' : $userData['data']['mobile']; //发票人手机
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$invoiceType = $orderInfo['invoiceType']; //发票类型ID
$invoices_type = $orderInfo['invoicesType'] * 1; //发票类型 /**纸质 1 ,电子 2 */
$mobile = isset($orderInfo['receiverMobile']) && !empty($orderInfo['receiverMobile']) ? $orderInfo['receiverMobile'] : $userMobile; //发票人手机
$invoices_title = $orderInfo['invoiceText']; //发票抬头
$invoice_Top = $orderInfo['invoiceTitle'];
}
else {
$userData = UserData::userData($uid);
$mobile = $userMobile; //发票人手机
$invoiceType = '7'; //发票类型ID
$invoices_type = '2'; //发票类型 /**纸质 1 ,电子 2 */
$invoice_Top = '个人';
}
$data = array(
'invoiceInfoPage' => true,
'invoiceNotice' => '发票须知',
'phone' => $mobile ? substr_replace($mobile, '****', 3, 4) : '',
'completeTel' => $mobile,
'isCompany' => $invoice_Top =='单位' ? false : true,
'companyName' => $invoices_title,
'invoicesType' => array(
array(
'id' => '2',
'type' => '电子发票',
'choosed' => empty($invoices_type) || $invoices_type == 2 ? true : false,
),
array(
'id' => '1',
'type' => '纸质发票',
'choosed' => $invoices_type == 1 ? true : false,
)
),
'invoiceTitle' => array(
array(
'type' => '个人',
'choosed' =>$invoice_Top == '个人'? true : false,
),
array(
'type' => '单位',
'choosed' => $invoice_Top == '单位' ? true : false,
)
),
'content' => array(
array(
'choosed' => empty($invoiceType) || $invoiceType == 7 ? true : false,
'id' => 7,
'text' => '服装'
),
array(
'choosed' => $invoiceType == 1 ? true : false,
'id' => 1,
'text' => '图书'
),
array(
'choosed' => $invoiceType == 9 ? true : false,
'id' => 9,
'text' => '配件'
),
array(
'choosed' => $invoiceType == 11 ? true : false,
'id' => 11,
'text' => '日用品'
),
array(
'choosed' => $invoiceType == 3 ? true : false,
'id' => 3,
'text' => '办公用品'
),
array(
'choosed' => $invoiceType == 6 ? true : false,
'id' => 6,
'text' => '体育用品'
),
array(
'choosed' => $invoiceType == 10 ? true : false,
'id' => 10,
'text' => '数码产品'
)
)
);
$this->setTitle('发票信息');
$this->setNavHeader('发票信息', true, false); // 不显示右上角home按钮
$this->_view->display('invoice-info', $data);
}
/**
* 购物车选择改变字段,重新运算订单数据
*/
public function orderComputeAction()
... ... @@ -557,22 +455,14 @@ class IndexController extends AbstractAction
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWay = $this->post('deliveryId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceText', null);
$invoiceId = $this->post('invoiceType', null);
$paymentId = $this->post('paymentTypeId', 15);
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('msg', null);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', 1);
$skuList = $this->post('skuList', '');
$cookieData = $this->getCookie('order-info', null); //获取电子发票信息
//电子发票信息数组
$invoices = array();
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$invoices['invoices_type_id'] = $orderInfo['invoiceType']; //发票类型ID
$invoices['invoices_type'] = $orderInfo['invoicesType']; //发票类型 /**纸质 1 ,电子 2 */
$invoices['receiverMobile'] = $orderInfo['receiverMobile']; //发票人手机
$invoices['invoices_title'] = empty($orderInfo['invoiceText']) ? '个人' : $orderInfo['invoiceText']; //发票抬头
}
/* 判断是否是友盟过来的用户 */
$userAgent = null;
... ... @@ -585,14 +475,16 @@ class IndexController extends AbstractAction
/* 模拟APP的User-Agent */
$userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null;
}
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $unionKey, $userAgent);
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $unionKey, $userAgent);
// 记录下单异常的数据
if (empty($result)) {
$message = 'uid:' . $uid . ',addressId:' . $addressId . ',cartType:' . $cartType . ',deliveryTime:' . $deliveryTime
. ',deliveryWay:' . $deliveryWay . ',yohoCoin:' . $yohoCoin
. ',deliveryWay:' . $deliveryWay . 'invoiceTitle:' . $invoiceTitle . ',invoiceId:' . $invoiceId . ',yohoCoin:' . $yohoCoin
. ',paymentId:' . $paymentId . ',paymentType:' . $paymentType . ',remark:' . $remark . ',couponCode:' . $couponCode . "\n";
UdpLog::info('【下单】下单异常数据', 'message:' . $message, '返回:' . json_encode($result));
error_log($message, 3, '/Data/logs/php/h5_error/order.' . date('Ym') . '.log');
UdpLog::info('【下单】下单异常数据','message:'.$message,'返回:'.json_encode($result));
}
// 返回数据
else {
... ... @@ -601,6 +493,14 @@ class IndexController extends AbstractAction
$this->echoJson($result);
}
/* if ($uid && !empty($result['data'])) {
try {
UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);
} catch (Exception $e) {
// do nothing
}
} */
}
else {
echo ' ';
... ...