一:checkout支付
1,后端接口的調(diào)用(獲取數(shù)據(jù)接口和發(fā)送數(shù)據(jù)接口)。
獲取數(shù)據(jù)
//從支付中心獲取銀行列表以及相關(guān)數(shù)據(jù)
$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);
其中函數(shù)makeSign()產(chǎn)生一個簽名,SendByCurl()向支付中心發(fā)送一個CURL請求。獲取的返回數(shù)據(jù)為:
返回結(jié)果 (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"
},
...//只顯示部分
]
}
}
發(fā)送數(shù)據(jù)
POST方法
路徑:https://paymenttest.comprame.com/api/doPayment
參數(shù)說明:
參數(shù) 必選 說明
bussinessId Yes OC的order ID
descption Yes 描述
currency Yes 貨幣類型 比如 COP USD
valueCOP Yes 換算成COP的金額
value Yes 支付的金額
buyerName Yes 購買者姓名
buyerEmail Yes 購買者郵箱
buyerContactPhone Yes 購買者聯(lián)系電話
buyerPhone Yes 購買者手機號碼
buyerDNI Yes 購買者身份證
buyerState Yes 購買者所在州
buyerCity Yes 購買者所在城市
buyerStreet Yes 購買者所在街道
responseUrl Yes 支付中心需要的回調(diào)路徑
_appid Yes 平臺ID 0 pc 1 安卓 2 IOS 3 H5
_ts Yes 當前調(diào)用接口時間的時間戳
_sign Yes 簽名
payment_platform Yes 支付平臺 目前兩種( payulatam,paypal)
payment_method Yes 支付方式 比如(VISA, MASTERCARD, BALOTO,PSE等)
activity No 優(yōu)惠活動
以下為信用卡需要的參數(shù)
card_name Yes 卡名
card_number Yes 卡號
expiration_date_year Yes 信用卡到期年份
expiration_date_month Yes 信用卡到期月份
security_code Yes 信用卡安全碼
is_save No 是否保存用戶信用卡
以下為PSE需要的參數(shù)
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 哥倫比亞)
注意:該方法調(diào)用之后不會返回值 會直接跳轉(zhuǎn)到支付中心的顯示頁面
這里是通過表單發(fā)送請求給支付中心的:
$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 = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Payulatam Checkout</title></head><body>';
$html .= '<form action="'.PAYMENT_SERVER.'" method="POST" id="form">';
foreach($form_data as $key=>$value){
$html .= '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
}
$html .= '</form>';
$html .= '<script type="text/javascript">document.getElementById("form").submit();</script>';
$html .= '</body></html>';
header('Content-Type: text/html;charset=utf-8;');
echo $html;
2,前臺頁面的數(shù)據(jù)校驗和顯示(信用卡信息顯示規(guī)則)
信用卡顯示規(guī)則為:當用戶有保存信用卡時候,用戶下次進入頁面時,頁面會顯示他保存的信用卡信息(安全碼除外)如圖:

圖片表示用戶上次保存了visa的支付方式,并且是他最近一次使用的支付方式。點擊其他支付方式時候,如果有保存則顯示他保存的信用卡信息,沒有則不處理。
二,訂閱功能
在www/H5/APP注冊的用戶,全部默認為訂閱用戶。遇到特殊的活動渠道,除了給新注冊用戶打上渠道標簽,還要為訂閱用戶打上標簽。訂閱用戶的活動標簽和新注冊是一樣的。通過FB登錄的用戶,讀取他們的注冊郵箱,并自動成為訂閱用戶。還有一種情況,營銷部門會單獨推出一些引導訂閱的活動,這些活動引來的訂閱用戶不一定是注冊用戶,因此我們還要區(qū)分訂閱的用戶是否是會員。
BI統(tǒng)計:

用戶取消訂閱和訂閱入口

當用戶輸入已經(jīng)是訂閱用戶的時候,表示用戶需要取消訂閱,反之則用戶需要訂閱,當用戶使用 第一次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后臺設(shè)置滿減產(chǎn)品,根據(jù)條件達到滿減的要求:
H5在三個頁面涉及到了滿減功能(\app\Model\Comprame\FulldiscountModel.php),
1,產(chǎn)品詳情頁面。
2,購物車頁面。
3,支付計算價格小計。
class FulldiscountModel extends BaseModel
{
public function fullReductionProduct()
{
$FullDiscount = $this->getFullDiscount();
return $FullDiscount;
}
//獲取符合滿減的產(chǎn)品總價格
public function inFullReductionTotal()
{
//參加滿減的產(chǎn)品數(shù)組
$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;
//選中的產(chǎn)品
$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 {
//繼續(xù)判斷下個符合滿減條件的金額
//前端需要顯示的滿減額度
$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
* 返回符合滿減條件的商品數(shù)組
*
*/
public function getFullDiscountProductionIds() {
$data = array();
//判斷是否開啟滿減
if ($this->config->get('full_discount_status')) {
//獲取滿減的開始時間跟結(jié)束時間
$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) {
//獲取后臺設(shè)置符合滿減的類型(-1:All; 1:部分分類商品; -1:除去此部分分類商品)
$full_discount_category_type = $this->config->get('full_discount_category_type');
if ($full_discount_category_type == -1) {
//-1,說明后臺設(shè)置所有的商品都符合滿減條件
$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數(shù)組
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;
}
四,活動頁面
頁面配置:(舉例)
配置產(chǎn)品和活動標題的方法,共3步驟:
1,配置頁面標題:OC后臺-> Extensions -> Page Template 新增
【Page Name】Americascup_160603,頁面標題和描述請參閱SVN 中的文檔進行設(shè)置。
2,配置頁面頂部banner:OC 后臺 -> System -> Design ->
Banners 新增,至少1張
【Banner Name】h5_cup01_topbanner
3,配置頁面產(chǎn)品: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”,返回列表,在列出的這個右側(cè)點擊“Add”,“Layout ” 選擇 “Americascup_160603”
五,波哥大銀行九折
支付中心請求PC端接口(目錄catalog\controller\payment\payulatam\latin_payu_notify()),當PC獲取到
//波哥大優(yōu)惠活動
$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'] : '';//實際付款貨幣
這些參數(shù)時候,表示參加了活動,活動方式記錄在$comments中,并且立馬更新訂單表(order表)并且在total表中記錄一條數(shù)據(jù)
前端頁面根據(jù)記錄的數(shù)據(jù)顯示相應(yīng)的東西(發(fā)票頁面,郵件頁面,支付成功頁面)
//如果是波哥大優(yōu)惠活動跟新訂單詳情
$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頁面商品管理功能開發(fā)需求
對網(wǎng)站后臺“Catalog-Categories-Category List-Edit Category”模塊進行優(yōu)化,
在現(xiàn)有顯示字段中增加”Model”的增、刪和顯示功能。
此功能可實現(xiàn)在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已經(jīng)存在分類
$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 = '<input type="checkbox" name="selected[]" value="' . $v['product_id'] . '" />';
$delete = '<button type="button" id="button-reset" class="btn btn-danger" onclick="confirm(\'Are you sure?\')?resetModel(' . $v['product_id'] . ',this):false;"><i class="fa fa-trash-o"></i></button>';
}
$html.=' <tr><td class="text-center">' . $select . '</td>
<td class="text-left">' . $v['product_id'] . '</td>
<td class="text-left"><img src="' . $v['image'] . '"></td>
<td class="text-right">' . $v['model'] . '</td>
<td class="text-left">' . $v['name'] . '</td>
<td class="text-left">' . $v['status'] . '</td>
<td class="text-right"> <a href="' . $v['history'] . '" data-toggle="tooltip" title="" class="btn btn-info" target="_blank"><i class="fa fa-eye"></i></a>
<a href="' . $v['edit'] . '" data-toggle="tooltip" title="" class="btn btn-primary" target="_blank"><i class="fa fa-pencil"></i></a>
' . $delete . '
</td>
</tr>';
}
}
return $html;
}
七,BI支付管理
BI系統(tǒng)連接支付數(shù)據(jù)庫,匹配出需要的數(shù)據(jù),頁面如下:

需要使用到的數(shù)據(jù)庫為(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'); //多選是數(shù)組
$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, ['系統(tǒng)ID', '訂單ID', 'RefernceCode', '渠道流水號', '貨幣', '金額', '狀態(tài)', '支付方式', '來源', '用戶名稱', '郵箱', '訂單聯(lián)系電話', '用戶聯(lián)系方式', '創(chuàng)建時間', '狀態(tài)修改時間'], ['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();
}