一:checkout支付
1,后端接口的调用(获取数据接口和发送数据接口)。
获取数据
//从支付中心获取银行列表以及相关数据
$this->load->model('checkout/pay');
$url = PAYMENT_SERVER . '/api/getPayData';
$form_data = array(
'_appid' => $this->APPID,
'_ts' => time(),
'userId' => $customer_id,
);
$form_data['_sign'] = $this->model_checkout_pay->makeSign('POST', '/api/getPayData', $this->APPKEY,$form_data);
$bank_user_info=$this->model_checkout_pay->SendByCurl($url,$form_data);
其中函数makeSign()产生一个签名,SendByCurl()向支付中心发送一个CURL请求。获取的返回数据为:
返回结果 (JSON实例)
{
"content": {
"cards": [ //客户信用卡信息 user_id不为空的时候才会有这个值
{
"id": "1",
"user_id": "1001",
"card_type": "VISA",
"card_name": "10222",
"card_number": "12546544545",
"expiration_date_year": "2018",
"expiration_date_month": "5",
"create_time": "0000-00-00 00:00:00",
"update_time": "0000-00-00 00:00:00"
}
],
"payment_limit": { //支付方式
"bank_transfer": {
"code": "bank_transfer",
"enable": 0,
"has_children": 0,
"detail": {
"handling": 10000
}
},
"paypal": {
"code": "paypal",
"enable": 0,
"has_children": 0
},
"payulatam": {
"code": "payulatam",
"enable": 1,
"has_children": 1,
"children": {
"VISA": {
"code": "VISA",
"enable": 1,
"has_children": 0,
"type": "credit_card",
"css_code": "visa",
"detail": {
"min_value": "0",
"max_value": "2800000"
}
},
"MASTERCARD": {
"code": "MASTERCARD",
"enable": 1,
"has_children": 0,
"type": "credit_card",
"css_code": "mastercard",
"detail": {
"min_value": "0",
"max_value": "2800000"
}
},
"AMEX": {
"code": "AMEX",
"enable": 1,
"has_children": 0,
"type": "credit_card",
"css_code": "amex",
"detail": {
"min_value": "0",
"max_value": "2800000"
}
},
"DINERS": {
"code": "DINERS",
"enable": 1,
"has_children": 0,
"type": "credit_card",
"css_code": "diners",
"detail": {
"min_value": "0",
"max_value": "2800000"
}
},
"BALOTO": {
"code": "BALOTO",
"enable": 1,
"has_children": 0,
"type": "cash",
"css_code": "baloto",
"detail": {
"min_value": "0",
"max_value": "490000"
}
},
"EFECTY": {
"code": "EFECTY",
"enable": 1,
"has_children": 0,
"type": "cash",
"css_code": "efecty",
"detail": {
"min_value": "30000",
"max_value": "900000"
}
},
"BANCOLOMBIA": {
"code": "BANCOLOMBIA",
"enable": 1,
"has_children": 0,
"type": "bank_referenced",
"css_code": "bancolombia"
},
"BANCODEBOGOTA": {
"code": "BANCODEBOGOTA",
"enable": 1,
"has_children": 0,
"type": "bank_referenced",
"css_code": "bancodebogota"
},
"PSE": {
"code": "PSE",
"enable": 1,
"has_children": 0,
"type": "pse",
"css_code": "pse"
}
}
}
},
"banks": [ //银行列表
{
"id": "5d11d1da-5ee4-43c7-ba26-6fa974b433d2",
"description": "BANCO AGRARIO",
"pseCode": "1040"
},
{
"id": "f33cd1fc-a257-4868-87a8-c4acac220236",
"description": "BANCO CAJA SOCIAL",
"pseCode": "1032"
},
{
"id": "e7c1183e-c61a-4bd1-9e7e-bf7b3669d0b6",
"description": "BANCO CAJA SOCIAL DESARROLLO",
"pseCode": "1132"
},
...//只显示部分
]
}
}
发送数据
POST方法
路径:https://paymenttest.comprame.com/api/doPayment
参数说明:
参数 必选 说明
bussinessId Yes OC的order ID
descption Yes 描述
currency Yes 货币类型 比如 COP USD
valueCOP Yes 换算成COP的金额
value Yes 支付的金额
buyerName Yes 购买者姓名
buyerEmail Yes 购买者邮箱
buyerContactPhone Yes 购买者联系电话
buyerPhone Yes 购买者手机号码
buyerDNI Yes 购买者身份证
buyerState Yes 购买者所在州
buyerCity Yes 购买者所在城市
buyerStreet Yes 购买者所在街道
responseUrl Yes 支付中心需要的回调路径
_appid Yes 平台ID 0 pc 1 安卓 2 IOS 3 H5
_ts Yes 当前调用接口时间的时间戳
_sign Yes 签名
payment_platform Yes 支付平台 目前两种( payulatam,paypal)
payment_method Yes 支付方式 比如(VISA, MASTERCARD, BALOTO,PSE等)
activity No 优惠活动
以下为信用卡需要的参数
card_name Yes 卡名
card_number Yes 卡号
expiration_date_year Yes 信用卡到期年份
expiration_date_month Yes 信用卡到期月份
security_code Yes 信用卡安全码
is_save No 是否保存用户信用卡
以下为PSE需要的参数
bank Yes 所在银行(值是从getPayData接口获取到的银行列表中的pseCode值)
telephone Yes 电话号码
customer_type Yes 用户类型 (N,J)
document_type Yes 证件类型(CC, CE, NIT, TI, PP,IDC, CEL, RC, DE)
payer_dni Yes 用户证件号
telephone_country Yes 电话号码所在国家 比如(CO 哥伦比亚)
注意:该方法调用之后不会返回值 会直接跳转到支付中心的显示页面
这里是通过表单发送请求给支付中心的:
$form_data=array(
'bussinessId' =>$order['order_id'],
'descption' =>$descption,
'currency' =>$order['currency_code'],
'valueCOP' =>$valueCOP,//支付中心用于支付金额
'value' =>$value,//支付中心用于显示
'buyerName' =>$order['payment_firstname'] . " " . $order['payment_lastname'],
'buyerEmail' =>$order['email'],
'buyerContactPhone' =>$order['telephone'], //会员表的电话
'buyerPhone' =>$order['shipping_telephone'], //下单地址里的电话
'buyerDNI' =>$order['idcard'],
'buyerState' =>$order['shipping_zone'],
'buyerStreet' =>$order['shipping_address_1'],
'buyerCity' =>$order['shipping_city'],
'responseUrl' =>$this->url->link('payment/payulatam/response', '', 'SSL'),
'_appid' =>$this->APPID,
'_ts' =>time()
);
$form_data['_sign'] = $this->makeSign('POST', '/', $this->APPKEY,$form_data);
$html = 'Payulatam Checkout ';
$html .= '';
$html .= '';
$html .= '';
header('Content-Type: text/html;charset=utf-8;');
echo $html;
2,前台页面的数据校验和显示(信用卡信息显示规则)
信用卡显示规则为:当用户有保存信用卡时候,用户下次进入页面时,页面会显示他保存的信用卡信息(安全码除外)如图:
图片表示用户上次保存了visa的支付方式,并且是他最近一次使用的支付方式。点击其他支付方式时候,如果有保存则显示他保存的信用卡信息,没有则不处理。
二,订阅功能
在www/H5/APP注册的用户,全部默认为订阅用户。遇到特殊的活动渠道,除了给新注册用户打上渠道标签,还要为订阅用户打上标签。订阅用户的活动标签和新注册是一样的。通过FB登录的用户,读取他们的注册邮箱,并自动成为订阅用户。还有一种情况,营销部门会单独推出一些引导订阅的活动,这些活动引来的订阅用户不一定是注册用户,因此我们还要区分订阅的用户是否是会员。
BI统计:
用户取消订阅和订阅入口
当用户输入已经是订阅用户的时候,表示用户需要取消订阅,反之则用户需要订阅,当用户使用 第一次FB登陆的时候默认成为订阅用户(代码文件为catalog\controller\module\journal2_newsletter.php)。
public function subscribe() {
$response = array();
if ($this->validateEmail()) {
// $newsletter = new Journal2Newsletter($this->registry, $this->request->post['email']);
$newsletter = new Journal2Newsletter($this->registry, $this->request->post['email'],$this->request->post);
if ($newsletter->isSubscribed()) {
$response['status'] = 'error';
$response['unsubscribe'] = 1;
$response['message'] = $this->journal2->settings->get('newsletter_confirm_unsubscribe_message', 'Ya está inscrito en nuestro boletín de noticias y promociones. Desea darse de baja?');
} else {
$newsletter->subscribe();
$response['status'] = 'success';
$response['message'] = $this->journal2->settings->get('newsletter_subscribed_message', 'Gracias por suscribirse a
nuestro boletín de noticias y promociones.');
}
} else {
$response['status'] = 'error';
$response['message'] = $this->journal2->settings->get('newsletter_invalid_email_message', 'correo electrónico no válida.');
}
$this->response->setOutput(json_encode($response));
}
public function unsubscribe() {
$response = array();
if ($this->validateEmail()) {
$newsletter = new Journal2Newsletter($this->registry, $this->request->post['email']);
if ($newsletter->isSubscribed()) {
$newsletter->unsubscribe();
$response['status'] = 'success';
$response['message'] = $this->journal2->settings->get('newsletter_unsubscribed_message',
'Se ha dado de bajo de nuestro boletín de noticias y promociones.');
} else {
$response['status'] = 'error';
$response['message'] = 'Your E-Mail was not found.';
}
} else {
$response['status'] = 'error';
$response['message'] = $this->journal2->settings->get('newsletter_invalid_email_message', 'correo electrónico no válida.');
}
$this->response->setOutput(json_encode($response));
}
三,满减H5
通过PC后台设置满减产品,根据条件达到满减的要求:
H5在三个页面涉及到了满减功能(\app\Model\Comprame\FulldiscountModel.php),
1,产品详情页面。
2,购物车页面。
3,支付计算价格小计。
class FulldiscountModel extends BaseModel
{
public function fullReductionProduct()
{
$FullDiscount = $this->getFullDiscount();
return $FullDiscount;
}
//获取符合满减的产品总价格
public function inFullReductionTotal()
{
//参加满减的产品数组
$full_discount_total = '';
$full_discount_product_list = $this->fullReductionProduct();
$full_discount_product_id = $full_discount_product_list['product_ids'];
//print_r($full_discount_product_list);die;
//选中的产品
$cart_select_list = Cart::getInstance()->getProducts();
if ($full_discount_product_id === true) {
//后台选择了All,所有商品都符合满减条件
$full_discount_total = Cart::getInstance()->getSubTotal(1);
} elseif ($full_discount_product_id === false) {
//没有符合满减条件的商品,不用计算
$full_discount_total = 0;
} else {
if (count($cart_select_list) && count($full_discount_product_id)) {
foreach ($cart_select_list as $_cval) {
if (in_array($_cval['product_id'], $full_discount_product_id)) {
$full_discount_total += $_cval['total_usd'];
}
}
}
}
return $full_discount_total;
}
//显示满减的金额
public function showDiscount()
{
$full_discount_product_list = $this->fullReductionProduct();
$full_money = $full_discount_product_list['full_discount_money'];
$full_discount_url = $full_discount_product_list['full_discount_url'];
$full_discount_status = $full_discount_product_list['full_discount_status'];
$full_discount_total = $this->inFullReductionTotal();
if (!empty($full_discount_product_list) && !empty($full_money)) {
$first_full_discount = key($full_money);
}
if (count($full_money) > 0 && !empty($full_money)) {
foreach ($full_money as $_nkey => $_nval) {
$need = $_nkey - $full_discount_total; //满减条件金额 - 当前购物车符合满减条件的金额
$full = Currency::getInstance()->format($_nkey);
$discount = Currency::getInstance()->format($_nval);
if ($need > 0) {
//仍需要多少金额才可以达到满减条件,只在第一阶梯显示提示“还差多少元符合满减条件”
if ($_nkey == $first_full_discount) {
$data['full_discount_show_discount'] = '';
$data['full_discount_hiden_discount'] = '';
}
break;
} else {
//继续判断下个符合满减条件的金额
//前端需要显示的满减额度
$data['full_discount_show_discount'] = '-' . $discount;
$data['full_discount_hiden_discount'] = $_nval;
continue;
}
}
$data['full_discount_url'] = $full_discount_url;
$data['full_discount_status'] = $full_discount_status;
} else {
$data['full_discount_hiden_discount'] = '';
$data['full_discount_show_discount'] = '';
$data['full_discount_url'] = '';
$data['full_discount_status'] = '';
}
return $data;
}
public function getFullDiscount($product_id = '')
{
$data = $this->api->get('v2/product/product/getProductionIdByFullDiscount', array(
'product_id' => $product_id,
));
return $data;
}
API 代码
/**
* by lxb
* 返回符合满减条件的商品数组
*
*/
public function getFullDiscountProductionIds() {
$data = array();
//判断是否开启满减
if ($this->config->get('full_discount_status')) {
//获取满减的开始时间跟结束时间
$full_discount_start_time = strtotime($this->config->get('full_discount_date_start'));
$full_discount_end_time = strtotime($this->config->get('full_discount_date_end'));
$db_now = $this->db->query("select now() no ")->row['no'];
$time = strtotime($db_now);
if ($time >= $full_discount_start_time && $time <= $full_discount_end_time) {
//获取后台设置符合满减的类型(-1:All; 1:部分分类商品; -1:除去此部分分类商品)
$full_discount_category_type = $this->config->get('full_discount_category_type');
if ($full_discount_category_type == -1) {
//-1,说明后台设置所有的商品都符合满减条件
$data['product_id']=TRUE;
} elseif ($full_discount_category_type == 1) {
//获取符合满减条件的分类ID
$full_discount_category = $this->config->get('full_discount_category');
$categorys = rtrim($full_discount_category, ',');
if ($categorys) {
$category_product_query = $this->db->query("SELECT DISTINCT product_id FROM " . DB_PREFIX . "product_to_category WHERE category_id IN (" . $categorys . ")");
if ($category_product_query->num_rows) {
foreach ($category_product_query->rows as $cval) {
$data['product_id'][] = $cval['product_id'];
}
}
//$this->cache->set('fullDiscountCategorys_'.$full_discount_category, $data);
//return $data;
} else {
//如果没有符合满减条件的商品,那么所有的商品都不符合满减条件
$data['product_id']=FALSE;
}
} elseif ($full_discount_category_type == 2) {
//除去此部分分类的商品
$full_discount_category = $this->config->get('full_discount_category');
$categorys = rtrim($full_discount_category, ',');
if ($categorys) {
$category_product_query = $this->db->query("SELECT DISTINCT product_id FROM " . DB_PREFIX . "product_to_category WHERE category_id IN (" . $categorys . ")");
$categorys_product_arr = array();
//获取要去除的商品ID数组
if ($category_product_query->num_rows) {
foreach ($category_product_query->rows as $cval) {
$categorys_product_arr[] = $cval['product_id'];
}
}
if (count($categorys_product_arr)) {
$not_full_discount_ids = implode(',', $categorys_product_arr);
$product_list_query = $this->db->query("SELECT DISTINCT product_id FROM " . DB_PREFIX . "product WHERE product_id NOT IN (".$not_full_discount_ids.")");
if ($product_list_query->num_rows) {
foreach ($product_list_query->rows as $pval) {
$data['product_id'][] = $pval['product_id'];
}
}
//return $data;
} else {
//如果要去除的商品为空,那么就是所有商品都符合满减条件
$data['product_id']=TRUE;
}
}else{
//如果要去除的商品为空,那么就是所有商品都符合满减条件
$data['product_id']=TRUE;
}
}
}
}
return $data;
}
四,活动页面
页面配置:(举例)
配置产品和活动标题的方法,共3步骤:
1,配置页面标题:OC后台-> Extensions -> Page Template 新增
【Page Name】Americascup_160603,页面标题和描述请参阅SVN 中的文档进行设置。
2,配置页面顶部banner:OC 后台 -> System -> Design ->
Banners 新增,至少1张
【Banner Name】h5_cup01_topbanner
3,配置页面产品:OC后台-> Journal2 -> Dashboard -> Carousel -> 新增Create New:
【Module Name】输入
Americascup_160603
【Module Type】选择 Category
点击“Add Tab+”新增一个Tab,“Section Name” 输入 【Relojes Unisex】,“Category” 选中【Custom】,“Categories” 点击Add 添加选择。
依次再按照如此方法,新增剩余2个Tab,Section Name 分别是【Gafas del sol】【Vida inteligente】
再点击“Save”,返回列表,再点击“Save”,返回列表,在列出的这个右侧点击“Add”,“Layout ” 选择 “Americascup_160603”
五,波哥大银行九折
支付中心请求PC端接口(目录catalog\controller\payment\payulatam\latin_payu_notify()),当PC获取到
//波哥大优惠活动
$comments = isset($args['payComment']) ? $args['payComment'] : '';//付款备注
$pay_method = isset($args['payMethod']) ? $args['payMethod'] : '';//付款方式
$pay_totals = isset($args['payTotal']) ? $args['payTotal'] : '';//实际付款金额
$pay_currency = isset($args['payCurrency']) ? $args['payCurrency'] : '';//实际付款货币
这些参数时候,表示参加了活动,活动方式记录在$comments中,并且立马更新订单表(order表)并且在total表中记录一条数据
前端页面根据记录的数据显示相应的东西(发票页面,邮件页面,支付成功页面)
//如果是波哥大优惠活动跟新订单详情
$this->model_checkout_order->updateOrderComment($order_id,$pay_currency,$pay_total,$pay_method);
if(!$this->model_checkout_order->isTotal($order_id)){
$this->model_checkout_order->addOrderTotal($order_id,$pay_total);
}
六,Category页面商品管理功能开发需求
对网站后台“Catalog-Categories-Category List-Edit Category”模块进行优化,
在现有显示字段中增加”Model”的增、删和显示功能。
此功能可实现在Category页面中管理该Category下所有的商品,
改变原来需要逐个Product添加Category的操作模式,提高品类管理效率。
在PC后台的类目管理->编辑类目->model下管理该类目下的所有model
添加model的时候每个model按逗号隔开,可以对每一个model进行增,删(如果该model的主分类是这个则无法删除),因为每次提交刷新都会跳到第一个type,为了增加效率,所以我全部采用的是ajax方式对这些model进行操作,代码如下:
//给分类添加MODEL
function addModel(){
$this->load->model('catalog/category');
$json=$model=$exist_model=$success_model=$no_exist_model=[];
$value=0;
$model_name = $this->request->post['model_name'];
$category_id = $this->request->get['category_id'];
$model= explode(',', $model_name);
if(empty($model_name)||!is_array($model)){
$value=1;
}
if(is_array($model)){
foreach($model as $val){
$results = $this->model_catalog_category->isModel($val);
if($results){
if($this->model_catalog_category->isProductCategory($results['product_id'],$category_id)){
//model已经存在分类
$exist_model[]=$val;
}else{
$this->model_catalog_category->addProductCategory($results['product_id'],$category_id);
$success_model[]=$val;
}
}else{
//model不存在
$no_exist_model[]=$val;
}
}
}
$html=$this->addHtml($category_id);
$json = array(
'value' =>$value ,
'exist_model' =>$exist_model?$exist_model=implode(',',$exist_model):0 ,
'success_model' => $success_model?$success_model=implode(',',$success_model):0,
'no_exist_model' => $no_exist_model?$no_exist_model=implode(',',$no_exist_model):0,
'html'=>$html?:'',
);
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function deleteModel(){
$this->load->model('catalog/category');
$json=[];
$delete=1;
$product_id = $this->request->post['product_id'];
$category_id = $this->request->get['category_id'];
$this->model_catalog_category->deleteModel($product_id,$category_id);
if($this->model_catalog_category->isProductCategory($product_id,$category_id)){
$delete=2;//删除不成功
}
$json = array(
'delete' =>$delete ,
);
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
function deleteSomeModel(){
$this->load->model('catalog/category');
$category_id = $this->request->get['category_id'];
$product_id = rtrim($this->request->post['product_id'],',');
$product_id= explode(',', $product_id);
if(!empty($product_id)){
foreach($product_id as $v){
$this->model_catalog_category->deleteModel($v,$category_id);
}
}
$html=$this->addHtml($category_id);
$json = array(
'html' =>$html?:'',
);
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function addHtml($category_id) {
$this->load->model('tool/image');
$model = $this->model_catalog_category->getCategoryModel($category_id);
if (!empty($model)) {
foreach ($model as $v) {
$v['image'] = $this->model_tool_image->resize($v['image'], 40, 40, true);
$v['status'] == 1 ? $v['status'] = 'YES' : $v['status'] = 'NO';
$select = '';
$delete = '';
$v['edit'] = $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $v['product_id'], 'SSL');
$v['history'] = $this->url->link('catalog/product/history', 'token=' . $this->session->data['token'] . '&product_id=' . $v['product_id'], 'SSL');
if ($v['is_defaul'] == 0) {
$select = '';
$delete = '';
}
$html.=' ' . $select . '
' . $v['product_id'] . '
' . $v['model'] . '
' . $v['name'] . '
' . $v['status'] . '
' . $delete . '
';
}
}
return $html;
}
七,BI支付管理
BI系统连接支付数据库,匹配出需要的数据,页面如下:
需要使用到的数据库为(pay_order,pay_request,pay_payu_request_submit,pay_payu_transaction)
/**
* 支付管理
*/
public function payAction()
{
$psyModel = PayModel::getInstance();
$orderCountModel = OrderCountModel::getInstance();
$page = intval($this->get('page', 1));
$share = intval($this->get('is_share'));
$startDate = $this->get('start_date');
$endDate = $this->get('end_date');
$bussiness_id = trim($this->get('bussiness_id'));
$referncecode = trim($this->get('referncecode'));
$payu_order_id = trim($this->get('payu_order_id'));
$currency = $this->get('currency');
$request = $this->get('request');
$state = $this->get('state'); //多选是数组
$state = is_array($state) ? implode(',', $this->get('state')) : $state;
$payment = $this->get('payment');
$payment = is_array($payment) ? implode(',', $this->get('payment')) : $payment;
$appid = $this->get('appid');
$appid = is_array($appid) ? implode(',', $this->get('appid')) : $appid;
$filter = [
'start_date' => $startDate,
'end_date' => $endDate,
'bussiness_id' => $bussiness_id,
'referncecode' => $referncecode,
'payu_order_id' => $payu_order_id,
'currency' => $currency,
'state' => $state,
'payment' => $payment,
'appid' => $appid,
'request' => $request,
'is_share' => $share,
];
$total = 0;
$orders = $psyModel->payOrder($filter, $total);
$params = $filter;
$data = array();
if ($orders) {
foreach ($orders as $order) {
//最新的一条请求
$requestModel = $psyModel->payRequest($order['id']);
if ($requestModel) {
$order['request'] = $requestModel;
$payuSubmitModel = $psyModel->payRequestSubmit($requestModel['id']);
if (!empty($payuSubmitModel)) {
$order['submit'] = $payuSubmitModel;
$transactionModel = $psyModel->payRequestTransaction($payuSubmitModel['id']);
if (!empty($transactionModel)) {
$order['payu_transaction'] = $transactionModel;
}
}
}
$flag = true;
if (isset($referncecode) && $referncecode != '' && $flag) {
if (isset($order['submit']['reference_code']) && $order['submit']['reference_code'] != '' && $order['submit']['reference_code'] == $referncecode) {
$flag = true;
} else {
$flag = false;
}
}
if (isset($payu_order_id) && $payu_order_id != '' && $flag) {
if (isset($order['payu_transaction']['payu_order_id']) && $order['payu_transaction']['payu_order_id'] != '' && $order['payu_transaction']['payu_order_id'] == $payu_order_id) {
$flag = true;
} else {
$flag = false;
}
}
if (isset($currency) && $currency != '' && $flag) {
if (isset($order['request']['currency']) && $order['request']['currency'] != '' && $order['request']['currency'] == $currency) {
$flag = true;
} else {
$flag = false;
}
}
if (isset($payment) && $payment != '' && $flag) {
if (isset($order['submit']['payment_method']) && $order['submit']['payment_method'] != '' && strstr($payment, $order['submit']['payment_method'])) {
$flag = true;
} else {
$flag = false;
}
}
if (isset($appid) && $appid != '' && $flag) {
if (isset($order['request']['app_id']) && $order['request']['app_id'] != '' && strstr($appid, $order['request']['app_id'])) {
$flag = true;
} else {
$flag = false;
}
}
if ($flag) {
$data[] = $order;
}
}
}
if ($request == 'yes') {
foreach ($data as $key => $v) {
if (isset($v['submit'])) {
if (!$v['submit']['payment_method']) {
unset($data[$key]);
}
} elseif (!isset($v['submit'])) {
unset($data[$key]);
}
}
$data = array_merge($data);
} elseif ($request == 'no') {
foreach ($data as $key => $v) {
if (isset($v['submit'])) {
if ($v['submit']['payment_method']) {
unset($data[$key]);
}
}
}
$data = array_merge($data);
}
if (isset($data)) {
$total = count($data);
} else {
$total = 0;
}
$result = array();
$i = ($page * $this->pageSize) - 1;
$k = ($page - 1) * $this->pageSize - 1;
foreach ($data as $key => $v) {
if ($key <= $i && $key > $k) {
$result[] = $data[$key];
}
}
$pager = new Pager($page, $this->pageSize, $total, CUR_ROUTE, $params);
$page = $pager->makeHtml();
if ($result) {
foreach ($result as $k => &$v) {
if (isset($v['state'])) {
switch ($v['state']) {
case 5:
$result[$k]['state'] = '支付成功';
break;
case 4:
$result[$k]['state'] = '过期';
break;
case 3:
$result[$k]['state'] = '支付待确认';
break;
case 2:
$result[$k]['state'] = '待支付';
break;
}
}
if (isset($v['request'])) {
switch ($v['request']['app_id']) {
case 0:
$result[$k]['request']['app_id'] = 'PC';
break;
case 1:
$result[$k]['request']['app_id'] = '安卓';
break;
case 2:
$result[$k]['request']['app_id'] = 'IOS';
break;
case 3:
$result[$k]['request']['app_id'] = 'H5';
break;
}
}
}
}
$export = array();
if ($result) {
foreach ($result as $key => $vs) {
$export[$key]['transaction_id'] = $vs['id'];
$export[$key]['bussiness_id'] = $vs['bussiness_id'];
$export[$key]['reference_code'] = isset($vs['submit']['reference_code']) ? $vs['submit']['reference_code'] : '';
$export[$key]['payu_order_id'] = isset($vs['payu_transaction']['payu_order_id']) ? $vs['payu_transaction']['payu_order_id'] : '';
$export[$key]['currency'] = isset($vs['request']['currency']) ? $vs['request']['currency'] : '';
$export[$key]['value'] = isset($vs['request']['value']) ? $vs['request']['value'] : '';
$export[$key]['buyer_name'] = isset($vs['request']['buyer_name']) ? $vs['request']['buyer_name'] : '';
$export[$key]['buyer_email'] = isset($vs['request']['buyer_email']) ? $vs['request']['buyer_email'] : '';
$export[$key]['buyer_contact_phone'] = isset($vs['request']['buyer_contact_phone']) ? $vs['request']['buyer_contact_phone'] : '';
$export[$key]['buyer_phone'] = isset($vs['request']['buyer_phone']) ? $vs['request']['buyer_phone'] : '';
$export[$key]['state'] = $vs['state'];
$export[$key]['payment_method'] = isset($vs['submit']['payment_method']) ? $vs['submit']['payment_method'] : '';
$export[$key]['app_id'] = isset($vs['request']['app_id']) ? $vs['request']['app_id'] : '';
$export[$key]['create_time'] = $vs['create_time'];
$export[$key]['modify_time'] = $vs['modify_time'];
}
}
$this->checkExport($export, ['系统ID', '订单ID', 'RefernceCode', '渠道流水号', '货币', '金额', '状态', '支付方式', '来源', '用户名称', '邮箱', '订单联系电话', '用户联系方式', '创建时间', '状态修改时间'], ['transaction_id', 'bussiness_id', 'reference_code', 'payu_order_id', 'currency', 'value', 'state', 'payment_method', 'app_id', 'buyer_name', 'buyer_email', 'buyer_contact_phone', 'buyer_phone', 'create_time', 'modify_time']);
$this->assign([
'offset' => ($page - 1) * $this->pageSize,
'result' => $result,
'filter' => $filter,
'pageBar' => $page,
'total' => $total,
]);
$this->display();
}