提交 d9ecaa7d 编写于 作者: D devil

支付日志优化

上级 46d7799d
...@@ -68,34 +68,69 @@ class Paylog ...@@ -68,34 +68,69 @@ class Paylog
'form_type' => 'select', 'form_type' => 'select',
'form_name' => 'payment', 'form_name' => 'payment',
'where_type' => 'in', 'where_type' => 'in',
'data' => $this->PayLogTypeList(), 'data' => $this->PayLogPaymentTypeList(),
'data_key' => 'id', 'data_key' => 'id',
'data_name' => 'name', 'data_name' => 'name',
'is_multiple' => 1, 'is_multiple' => 1,
], ],
], ],
[
'label' => '状态',
'view_type' => 'field',
'view_key' => 'status',
'view_data_key' => 'name',
'view_data' => lang('common_pay_log_status_list'),
'search_config' => [
'form_type' => 'select',
'where_type' => 'in',
'data' => lang('common_pay_log_status_list'),
'data_key' => 'value',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[ [
'label' => '业务类型', 'label' => '业务类型',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'business_type', 'view_key' => 'business_type',
'view_data_key' => 'name',
'view_data' => lang('common_business_type_list'),
'search_config' => [ 'search_config' => [
'form_type' => 'select', 'form_type' => 'select',
'where_type' => 'in', 'where_type' => 'in',
'data' => lang('common_business_type_list'), 'data' => $this->PayLogBusinessTypeList(),
'data_key' => 'id', 'data_key' => 'name',
'data_name' => 'name', 'data_name' => 'name',
'is_multiple' => 1, 'is_multiple' => 1,
], ],
], ],
[ [
'label' => '业务订单id', 'label' => '业务id/单号',
'view_type' => 'module',
'view_key' => 'paylog/module/business_list',
'width' => 300,
'search_config' => [
'form_type' => 'input',
'form_name' => 'id',
'where_type' => 'like',
'where_type_custom' => 'in',
'where_handle_custom' => 'WhereValueBusinessInfo',
],
],
[
'label' => '业务订单金额(元)',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'order_id', 'view_key' => 'total_price',
'search_config' => [ 'search_config' => [
'form_type' => 'input', 'form_type' => 'section',
'where_type' => '=', 'is_point' => 1,
],
],
[
'label' => '支付金额(元)',
'view_type' => 'field',
'view_key' => 'pay_price',
'search_config' => [
'form_type' => 'section',
'is_point' => 1,
], ],
], ],
[ [
...@@ -104,7 +139,7 @@ class Paylog ...@@ -104,7 +139,7 @@ class Paylog
'view_key' => 'trade_no', 'view_key' => 'trade_no',
'search_config' => [ 'search_config' => [
'form_type' => 'input', 'form_type' => 'input',
'where_type' => 'like', 'where_type' => '=',
], ],
], ],
[ [
...@@ -117,39 +152,36 @@ class Paylog ...@@ -117,39 +152,36 @@ class Paylog
], ],
], ],
[ [
'label' => '支付金额', 'label' => '订单名称',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'pay_price', 'view_key' => 'subject',
'search_config' => [ 'search_config' => [
'form_type' => 'section', 'form_type' => 'input',
'is_point' => 1, 'where_type' => 'like',
], ],
], ],
[ [
'label' => '订单实际金额', 'label' => '支付时间',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'total_price', 'view_key' => 'pay_time',
'search_config' => [ 'search_config' => [
'form_type' => 'section', 'form_type' => 'datetime',
'is_point' => 1,
], ],
], ],
[ [
'label' => '订单名称', 'label' => '关闭时间',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'subject', 'view_key' => 'close_time',
'search_config' => [ 'search_config' => [
'form_type' => 'input', 'form_type' => 'datetime',
'where_type' => 'like',
], ],
], ],
[ [
'label' => '支付时间', 'label' => '创建时间',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'add_time_time', 'view_key' => 'add_time',
'search_config' => [ 'search_config' => [
'form_type' => 'datetime', 'form_type' => 'datetime',
'form_name' => 'add_time',
], ],
], ],
[ [
...@@ -194,10 +226,46 @@ class Paylog ...@@ -194,10 +226,46 @@ class Paylog
* @date 2020-06-26 * @date 2020-06-26
* @desc description * @desc description
*/ */
public function PayLogTypeList() public function PayLogPaymentTypeList()
{ {
$ret = PayLogService::PayLogTypeList(); $ret = PayLogService::PayLogTypeList();
return empty($ret['data']) ? [] : $ret['data']; return empty($ret['data']) ? [] : $ret['data'];
} }
/**
* 业务类型
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-26
* @desc description
*/
public function PayLogBusinessTypeList()
{
return Db::name('PayLog')->field('business_type as name')->group('business_type')->select();
}
/**
* 关联业务条件处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-30
* @desc description
* @param [string] $value [条件值]
* @param [array] $params [输入参数]
*/
public function WhereValueBusinessInfo($value, $params = [])
{
if(!empty($value))
{
// 获取支持业务支付 id
$ids = Db::name('PayLogValue')->where('business_id|business_no', '=', $value)->column('pay_log_id');
// 避免空条件造成无效的错觉
return empty($ids) ? [0] : $ids;
}
return $value;
}
} }
?> ?>
\ No newline at end of file
<!-- 关联业务数据 -->
{{if !empty($module_data) and !empty($module_data['business_list']) and is_array($module_data['business_list'])}}
<dl class="dl-content dl-content-dd-only">
{{foreach $module_data.business_list as $v}}
<dd>
<div class="am-nbfc">
{{if !empty($v['business_id'])}}
<span class="am-icon-circle-thin am-fl">
<strong>{{$v.business_id}}</strong>
</span>
{{/if}}
{{if !empty($v['business_no'])}}
<span class="am-icon-bookmark-o am-fr">
<strong>{{$v.business_no}}</strong>
</span>
{{/if}}
</div>
</dd>
{{/foreach}}
</dl>
{{/if}}
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{{/if}} {{/if}}
{{if isset($module_data['payment'])}} {{if isset($module_data['payment'])}}
<p> <p>
<span class="am-badge am-radius">{{$module_data.payment}}</span> <span class="am-badge am-badge-secondary-plain am-radius">{{$module_data.payment}}</span>
</p> </p>
{{/if}} {{/if}}
{{/if}} {{/if}}
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{{/if}} {{/if}}
{{if isset($module_data['payment'])}} {{if isset($module_data['payment'])}}
<p> <p>
<span class="am-badge am-radius">{{$module_data.payment}}</span> <span class="am-badge am-badge-secondary-plain am-radius">{{$module_data.payment}}</span>
</p> </p>
{{/if}} {{/if}}
{{/if}} {{/if}}
\ No newline at end of file
<!-- 基础信息 --> <!-- 基础信息 -->
{{if !empty($module_data)}} {{if !empty($module_data)}}
{{if !empty($module_data['name'])}} {{if !empty($module_data['name'])}}
<p>{{$module_data.name}}{{if isset($module_data['is_default']) and $module_data['is_default'] eq 1}}<span class="am-badge am-badge-success am-round am-margin-left-xs">默认</span>{{/if}}</p> <p>{{$module_data.name}}{{if isset($module_data['is_default']) and $module_data['is_default'] eq 1}}<span class="am-badge am-badge-success-plain am-round am-margin-left-xs">默认</span>{{/if}}</p>
{{/if}} {{/if}}
{{if !empty($module_data['alias'])}} {{if !empty($module_data['alias'])}}
<p class="am-badge am-badge-secondary am-radius">{{$module_data.alias}}</p> <p class="am-badge am-badge-secondary-plain am-radius">{{$module_data.alias}}</p>
{{/if}} {{/if}}
{{/if}} {{/if}}
\ No newline at end of file
...@@ -130,5 +130,78 @@ class Devtest extends Common ...@@ -130,5 +130,78 @@ class Devtest extends Common
} }
echo 'count:'.count($result).', success:'.$success.', fail:'.$fail; echo 'count:'.count($result).', success:'.$success.', fail:'.$fail;
} }
/**
* 支付日志处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-26
* @desc description
*/
public function PayLogHandle()
{
if(input('pwd') != 'shopxo520')
{
die('非法访问');
}
// 状态
$success = 0;
$fail = 0;
// 获取日志
$data = Db::name('PayLog')->where(['is_handle'=>0])->limit(0, 500)->select();
if(!empty($data))
{
$business_type_list = [
0 => '默认',
1 => '订单',
2 => '充值',
3 => '提现',
];
foreach($data as $v)
{
$upd_data = [
'is_handle' => 1,
'business_type' => isset($business_type_list[$v['business_type']]) ? $business_type_list[$v['business_type']] : $v['business_type'],
'status' => (empty($v['pay_price']) || $v['pay_price'] <= 0) ? 0 : 1,
];
// 未支付则关闭
if(empty($v['pay_price']) || $v['pay_price'] <= 0)
{
$upd_data['close_time'] = time();
}
// 支付时间
if(!empty($v['pay_price']) && $v['pay_price'] > 0)
{
$upd_data['pay_time'] = time();
}
// 更新操作
if(Db::name('PayLog')->where(['is_handle'=>0, 'id'=>$v['id']])->update($upd_data))
{
// 新增关联数据
if(DB::name('PayLogValue')->insert([
'pay_log_id' => $v['id'],
'business_id' => $v['order_id'],
'business_no' => '',
'add_time' => $v['add_time'],
]))
{
$success++;
} else {
$fail++;
}
} else {
$fail++;
}
}
}
echo 'count:'.count($data).', success:'.$success.', fail:'.$fail;
}
} }
?> ?>
\ No newline at end of file
...@@ -78,6 +78,7 @@ class Order ...@@ -78,6 +78,7 @@ class Order
'not_show_data' => [0,2,3,4,5,6], 'not_show_data' => [0,2,3,4,5,6],
'align' => 'center', 'align' => 'center',
'width' => 80, 'width' => 80,
'view_key' => 'order_form_checkbox_value',
], ],
[ [
'label' => '基础信息', 'label' => '基础信息',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<!-- 表单顶部操作栏 --> <!-- 表单顶部操作栏 -->
{{block name="form_operate_top"}} {{block name="form_operate_top"}}
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-paypal"> 批量支付</button> <button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-paypal batch-pay-submit"> 批量支付</button>
<!-- 父级内容 --> <!-- 父级内容 -->
{__block__} {__block__}
{{/block}} {{/block}}
\ No newline at end of file
...@@ -366,6 +366,13 @@ return array( ...@@ -366,6 +366,13 @@ return array(
2 => array('value' => 2, 'name' => '已离职'), 2 => array('value' => 2, 'name' => '已离职'),
), ),
// 支付日志状态
'common_pay_log_status_list' => array(
0 => array('value' => 0, 'name' => '待支付', 'checked' => true),
1 => array('value' => 1, 'name' => '已支付'),
2 => array('value' => 2, 'name' => '已关闭'),
),
// 色彩值 // 色彩值
'common_color_list' => array( 'common_color_list' => array(
......
...@@ -93,7 +93,18 @@ class PayLogService ...@@ -93,7 +93,18 @@ class PayLogService
$data = Db::name('PayLog')->where($where)->field($field)->limit($m, $n)->order($order_by)->select(); $data = Db::name('PayLog')->where($where)->field($field)->limit($m, $n)->order($order_by)->select();
if(!empty($data)) if(!empty($data))
{ {
$refundment_list = lang('common_business_type_list'); // 获取支付业务关联数据
$log_value_list = [];
$log_value = Db::name('PayLogValue')->field('pay_log_id,business_id,business_no')->where(['pay_log_id'=>array_column($data, 'id')])->select();
if(!empty($log_value))
{
foreach($log_value as $lv)
{
$log_value_list[$lv['pay_log_id']][] = $lv;
}
}
// 循环处理数据
foreach($data as &$v) foreach($data as &$v)
{ {
// 用户信息 // 用户信息
...@@ -105,12 +116,13 @@ class PayLogService ...@@ -105,12 +116,13 @@ class PayLogService
} }
} }
// 业务类型 // 关联业务数据
$v['business_type_text'] = $refundment_list[$v['business_type']]['name']; $v['business_list'] = isset($log_value_list[$v['id']]) ? $log_value_list[$v['id']] : [];
// 时间 // 时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']); $v['add_time'] = empty($v['add_time']) ? '' : date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']); $v['pay_time'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']);
$v['close_time'] = empty($v['close_time']) ? '' : date('Y-m-d H:i:s', $v['close_time']);
} }
} }
return DataReturn('处理成功', 0, $data); return DataReturn('处理成功', 0, $data);
......
...@@ -252,15 +252,15 @@ class PaymentService ...@@ -252,15 +252,15 @@ class PaymentService
* @version 1.0.0 * @version 1.0.0
* @date 2018-09-19 * @date 2018-09-19
* @desc description * @desc description
* @param [int] $order_id [订单id] * @param [int|string] $business_value [业务订单id|单号]
* @param [int] $payment_id [支付方式id] * @param [int] $payment_id [支付方式id]
*/ */
public static function OrderPaymentName($order_id = 0, $payment_id = 0) public static function OrderPaymentName($business_value = 0, $payment_id = 0)
{ {
$name = null; $name = null;
if(!empty($order_id)) if(!empty($business_value))
{ {
$name = Db::name('PayLog')->where(['order_id'=>intval($order_id)])->value('payment_name'); $name = Db::name('PayLog')->alias('pl')->join(['__PAY_LOG_VALUE__'=>'plv'], 'pl.id=plv.pay_log_id')->where(['business_id|business_no'=>$business_value])->value('pl.payment_name');
if(empty($anme) && !empty($payment_id)) if(empty($anme) && !empty($payment_id))
{ {
$name = Db::name('Payment')->where(['id'=>intval($payment_id)])->value('name'); $name = Db::name('Payment')->where(['id'=>intval($payment_id)])->value('name');
......
此差异已折叠。
...@@ -1579,7 +1579,7 @@ function MapInit(lng, lat, level, point, is_dragend, mapid) ...@@ -1579,7 +1579,7 @@ function MapInit(lng, lat, level, point, is_dragend, mapid)
* @date 2020-02-29 * @date 2020-02-29
* @desc description * @desc description
*/ */
function TableContainerInit() function FormTableContainerInit()
{ {
if($('.am-table-scrollable-horizontal').length > 0) if($('.am-table-scrollable-horizontal').length > 0)
{ {
...@@ -1630,12 +1630,45 @@ function TableContainerInit() ...@@ -1630,12 +1630,45 @@ function TableContainerInit()
} }
} }
/**
* 动态表格选中的值
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-26
* @desc description
* @param {[string]} form [表单名称]
*/
function FromTableCheckedValues(form)
{
// 获取复选框选中的值
var values = [];
$('.am-table-scrollable-horizontal').find('input[name="'+form+'"]').each(function(key, tmp)
{
if($(this).is(':checked'))
{
values.push(tmp.value);
}
});
// 获取单选选中的值
if(values.length <= 0)
{
var val = $('.am-table-scrollable-horizontal input[name="'+form+'"]:checked').val();
if(val != undefined)
{
values.push(val);
}
}
return values;
}
// 公共数据操作 // 公共数据操作
$(function() $(function()
{ {
// 表格初始化 // 表格初始化
TableContainerInit(); FormTableContainerInit();
// 表格复选框操作 全选/反选 // 表格复选框操作 全选/反选
$('.form-table-operate-checkbox-submit').on('click', function() $('.form-table-operate-checkbox-submit').on('click', function()
...@@ -1673,27 +1706,8 @@ $(function() ...@@ -1673,27 +1706,8 @@ $(function()
return false; return false;
} }
// 获取复选框选中的值
var values = [];
$(document).find('input[name="'+form+'"]').each(function(key, tmp)
{
if($(this).is(':checked'))
{
values.push(tmp.value);
}
});
// 获取单选框的值
if(values.length <= 0)
{
var val = $('input[name="'+form+'"]:checked').val();
if(val != undefined)
{
values.push(val);
}
}
// 是否有选择的数据 // 是否有选择的数据
var values = FromTableCheckedValues(form);
if(values.length <= 0) if(values.length <= 0)
{ {
Prompt('请先选中数据'); Prompt('请先选中数据');
......
...@@ -83,4 +83,17 @@ $(function() ...@@ -83,4 +83,17 @@ $(function()
} }
} }
} }
// 批量支付
$('.batch-pay-submit').on('click', function()
{
// 是否有选择的数据
var values = FromTableCheckedValues('order_form_checkbox_value');
console.log(values)
if(values.length <= 0)
{
Prompt('请先选中数据');
return false;
}
});
}); });
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册