Files
shopxo/application/service/RefundLogService.php

138 lines
5.8 KiB
PHP
Raw Normal View History

2019-05-28 16:07:36 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\service;
use think\Db;
2020-06-27 22:48:16 +08:00
use app\service\UserService;
2019-05-28 16:07:36 +08:00
/**
* 退款日志服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class RefundLogService
{
/**
* 退款日志添加
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-07T00:57:36+0800
* @param [array] $params [输入参数]
* @param [int] $user_id [用户id]
2020-07-29 19:55:53 +08:00
* @param [int] $business_id [业务订单id]
2019-05-29 18:32:20 +08:00
* @param [float] $pay_price [业务订单实际支付金额]
2019-05-28 16:07:36 +08:00
* @param [string] $trade_no [支付平台交易号]
* @param [string] $buyer_user [支付平台用户帐号]
* @param [float] $refund_price [退款金额]
* @param [string] $msg [描述]
* @param [string] $payment [支付方式标记]
* @param [string] $payment_name [支付方式名称]
2019-05-30 16:30:06 +08:00
* @param [int] $refundment [退款类型0原路退回, 1退至钱包, 2手动处理)]
2020-07-29 19:55:53 +08:00
* @param [int] $business_type [业务类型,字符串(如:订单、钱包充值、会员购买、等...]
2019-05-28 16:07:36 +08:00
* @param [string] $return_params [支付平台返回参数]
* @return [boolean] [成功true, 失败false]
*/
public static function RefundLogInsert($params = [])
{
$data = [
'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0,
2020-07-29 19:55:53 +08:00
'business_id' => isset($params['business_id']) ? intval($params['business_id']) : 0,
2019-05-29 18:32:20 +08:00
'pay_price' => isset($params['pay_price']) ? PriceNumberFormat($params['pay_price']) : 0.00,
2019-05-28 16:07:36 +08:00
'trade_no' => isset($params['trade_no']) ? $params['trade_no'] : '',
'buyer_user' => isset($params['buyer_user']) ? $params['buyer_user'] : '',
'refund_price' => isset($params['refund_price']) ? PriceNumberFormat($params['refund_price']) : 0.00,
'msg' => isset($params['msg']) ? $params['msg'] : '',
'payment' => isset($params['payment']) ? $params['payment'] : '',
'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '',
2019-05-30 16:30:06 +08:00
'refundment' => isset($params['refundment']) ? intval($params['refundment']) : 0,
2020-07-29 19:55:53 +08:00
'business_type' => isset($params['business_type']) ? trim($params['business_type']) : 0,
2019-05-28 16:15:32 +08:00
'return_params' => empty($params['return_params']) ? '' : json_encode($params['return_params'], JSON_UNESCAPED_UNICODE),
2019-05-28 16:07:36 +08:00
'add_time' => time(),
];
return Db::name('RefundLog')->insertGetId($data) > 0;
}
/**
2019-05-29 18:32:20 +08:00
* 获取退款日志类型
2019-05-28 16:07:36 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-12-23T02:22:03+0800
* @param [array] $params [输入参数]
*/
2019-05-29 18:32:20 +08:00
public static function RefundLogTypeList($params = [])
2019-05-28 16:07:36 +08:00
{
2020-06-27 22:48:16 +08:00
$data = Db::name('RefundLog')->field('payment as id, payment_name as name')->group('payment,payment_name')->select();
2019-05-28 16:07:36 +08:00
return DataReturn('处理成功', 0, $data);
}
/**
2020-06-27 22:48:16 +08:00
* 列表
2019-05-28 16:07:36 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
2020-06-27 22:48:16 +08:00
public static function RefundLogList($params = [])
2019-05-28 16:07:36 +08:00
{
$where = empty($params['where']) ? [] : $params['where'];
$field = empty($params['field']) ? '*' : $params['field'];
$order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
2019-05-28 16:07:36 +08:00
$m = isset($params['m']) ? intval($params['m']) : 0;
$n = isset($params['n']) ? intval($params['n']) : 10;
// 获取数据列表
2020-06-27 22:48:16 +08:00
$data = Db::name('RefundLog')->where($where)->field($field)->limit($m, $n)->order($order_by)->select();
2019-05-28 16:07:36 +08:00
if(!empty($data))
{
2020-06-27 22:48:16 +08:00
$refundment_list = lang('common_order_aftersale_refundment_list');
2019-05-28 16:07:36 +08:00
foreach($data as &$v)
{
2020-06-27 22:48:16 +08:00
// 用户信息
if(isset($v['user_id']))
{
if(isset($params['is_public']) && $params['is_public'] == 0)
{
$v['user'] = UserService::GetUserViewInfo($v['user_id']);
}
}
2019-05-28 16:07:36 +08:00
2019-05-30 16:30:06 +08:00
// 退款方式
2020-06-27 22:48:16 +08:00
$v['refundment_text'] = $refundment_list[$v['refundment']]['name'];
2019-05-30 16:30:06 +08:00
2019-05-28 16:07:36 +08:00
// 时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']);
}
}
return DataReturn('处理成功', 0, $data);
}
/**
2020-06-27 22:48:16 +08:00
* 总数
2019-05-28 16:07:36 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $where [条件]
*/
2020-06-27 22:48:16 +08:00
public static function RefundLogTotal($where = [])
2019-05-28 16:07:36 +08:00
{
2020-06-27 22:48:16 +08:00
return (int) Db::name('RefundLog')->where($where)->count();
2019-05-28 16:07:36 +08:00
}
}
?>