From e4f75fed76be4ef4823f4092ed5be6a01ec344b9 Mon Sep 17 00:00:00 2001 From: devil Date: Wed, 29 Jul 2020 19:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=97=A5=E5=BF=97=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/form/Refundlog.php | 38 +++++++++++--- application/api/controller/Devtest.php | 49 +++++++++++++++++++ application/service/OrderAftersaleService.php | 6 +-- application/service/OrderService.php | 5 +- application/service/PayLogService.php | 2 +- application/service/RefundLogService.php | 12 ++--- 6 files changed, 91 insertions(+), 21 deletions(-) diff --git a/application/admin/form/Refundlog.php b/application/admin/form/Refundlog.php index e4b8511fa..2d4faca70 100644 --- a/application/admin/form/Refundlog.php +++ b/application/admin/form/Refundlog.php @@ -79,13 +79,11 @@ class Refundlog 'label' => '业务类型', 'view_type' => 'field', 'view_key' => 'business_type', - 'view_data_key' => 'name', - 'view_data' => lang('common_business_type_list'), 'search_config' => [ 'form_type' => 'select', 'where_type' => 'in', - 'data' => lang('common_business_type_list'), - 'data_key' => 'id', + 'data' => $this->RefundLogBusinessTypeList(), + 'data_key' => 'name', 'data_name' => 'name', 'is_multiple' => 1, ], @@ -93,10 +91,10 @@ class Refundlog [ 'label' => '业务订单id', 'view_type' => 'field', - 'view_key' => 'order_id', + 'view_key' => 'business_id', 'search_config' => [ - 'form_type' => 'input', - 'where_type' => '=', + 'form_type' => 'input', + 'where_type' => '=', ], ], [ @@ -214,8 +212,32 @@ class Refundlog */ public function RefundLogTypeList() { + $data = []; $ret = RefundLogService::RefundLogTypeList(); - return empty($ret['data']) ? [] : $ret['data']; + if(!empty($ret['data'])) + { + foreach($ret['data'] as $v) + { + $data[] = [ + 'id' => $v['id'], + 'name' => $v['name'].'('.$v['id'].')', + ]; + } + } + return $data; + } + + /** + * 业务类型 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-06-26 + * @desc description + */ + public function RefundLogBusinessTypeList() + { + return Db::name('RefundLog')->field('business_type as name')->group('business_type')->select(); } } ?> \ No newline at end of file diff --git a/application/api/controller/Devtest.php b/application/api/controller/Devtest.php index 347089fc2..f51655a4d 100644 --- a/application/api/controller/Devtest.php +++ b/application/api/controller/Devtest.php @@ -226,5 +226,54 @@ class Devtest extends Common } echo 'count:'.count($data).', success:'.$success.', fail:'.$fail; } + + /** + * 退款日志处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-26 + * @desc description + */ + public function RefundLogHandle() + { + if(input('pwd') != 'shopxo520') + { + die('非法访问'); + } + + // 状态 + $success = 0; + $fail = 0; + + + // 获取日志 + $data = Db::name('RefundLog')->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'], + ]; + + // 更新操作 + if(Db::name('RefundLog')->where(['is_handle'=>0, 'id'=>$v['id']])->update($upd_data)) + { + $success++; + } else { + $fail++; + } + } + } + echo 'count:'.count($data).', success:'.$success.', fail:'.$fail; + } } ?> \ No newline at end of file diff --git a/application/service/OrderAftersaleService.php b/application/service/OrderAftersaleService.php index e976a4578..3b6d5baa0 100644 --- a/application/service/OrderAftersaleService.php +++ b/application/service/OrderAftersaleService.php @@ -842,7 +842,7 @@ class OrderAftersaleService } // 订单支付方式校验 - $pay_log = Db::name('PayLog')->where(['order_id'=>$order['data']['id'], 'business_type'=>1])->find(); + $pay_log = Db::name('PayLog')->alias('pl')->join(['__PAY_LOG_VALUE_'=>'plv'], 'pl.id=plv.pay_log_id')->where(['plv.business_id'=>$order['data']['id'], 'pl.business_type'=>OrderService::$business_type_name])->field('pl.*')->find(); // 手动处理不校验支付日志 if($params['refundment'] != 2) @@ -1104,7 +1104,7 @@ class OrderAftersaleService // 写入退款日志 $refund_log = [ 'user_id' => $order['user_id'], - 'order_id' => $order['id'], + 'business_id' => $order['id'], 'pay_price' => $order['pay_price'], 'trade_no' => isset($ret['data']['trade_no']) ? $ret['data']['trade_no'] : '', 'buyer_user' => isset($ret['data']['buyer_user']) ? $ret['data']['buyer_user'] : '', @@ -1113,7 +1113,7 @@ class OrderAftersaleService 'payment' => $pay_log['payment'], 'payment_name' => $pay_log['payment_name'], 'refundment' => $params['refundment'], - 'business_type' => 1, + 'business_type' => OrderService::$business_type_name, 'return_params' => isset($ret['data']['return_params']) ? $ret['data']['return_params'] : '', ]; RefundLogService::RefundLogInsert($refund_log); diff --git a/application/service/OrderService.php b/application/service/OrderService.php index 85fd468db..6479395cc 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -31,6 +31,9 @@ use app\service\OrderAftersaleService; */ class OrderService { + // 业务类型名称 + public static $business_type_name = '订单'; + /** * 订单支付 * @author Devil @@ -306,7 +309,7 @@ class OrderService 'subject' => '订单支付', 'payment' => isset($params['payment']) ? $params['payment'] : '', 'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '', - 'business_type' => '订单', + 'business_type' => self::$business_type_name, ]); } diff --git a/application/service/PayLogService.php b/application/service/PayLogService.php index d6920b7ed..a45a796a0 100755 --- a/application/service/PayLogService.php +++ b/application/service/PayLogService.php @@ -32,7 +32,7 @@ class PayLogService * @param [int] $business_ids [业务订单id] * @param [float] $total_price [业务订单实际金额] * @param [string] $subject [业务订单名称] - * @param [int] $business_type [业务类型(0默认, 1订单, 2充值, ...)] + * @param [string] $business_type [业务类型,字符串(如:订单、钱包充值、会员购买、等...)] * @return [boolean] [成功true, 失败false] */ public static function PayLogInsert($params = []) diff --git a/application/service/RefundLogService.php b/application/service/RefundLogService.php index 91173f498..a4565f73a 100644 --- a/application/service/RefundLogService.php +++ b/application/service/RefundLogService.php @@ -30,7 +30,7 @@ class RefundLogService * @datetime 2019-05-07T00:57:36+0800 * @param [array] $params [输入参数] * @param [int] $user_id [用户id] - * @param [int] $order_id [业务订单id] + * @param [int] $business_id [业务订单id] * @param [float] $pay_price [业务订单实际支付金额] * @param [string] $trade_no [支付平台交易号] * @param [string] $buyer_user [支付平台用户帐号] @@ -39,7 +39,7 @@ class RefundLogService * @param [string] $payment [支付方式标记] * @param [string] $payment_name [支付方式名称] * @param [int] $refundment [退款类型(0原路退回, 1退至钱包, 2手动处理)] - * @param [int] $business_type [业务类型(0默认, 1订单, 2充值, ...)] + * @param [int] $business_type [业务类型,字符串(如:订单、钱包充值、会员购买、等...)] * @param [string] $return_params [支付平台返回参数] * @return [boolean] [成功true, 失败false] */ @@ -47,7 +47,7 @@ class RefundLogService { $data = [ 'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0, - 'order_id' => isset($params['order_id']) ? intval($params['order_id']) : 0, + 'business_id' => isset($params['business_id']) ? intval($params['business_id']) : 0, 'pay_price' => isset($params['pay_price']) ? PriceNumberFormat($params['pay_price']) : 0.00, 'trade_no' => isset($params['trade_no']) ? $params['trade_no'] : '', 'buyer_user' => isset($params['buyer_user']) ? $params['buyer_user'] : '', @@ -56,7 +56,7 @@ class RefundLogService 'payment' => isset($params['payment']) ? $params['payment'] : '', 'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '', 'refundment' => isset($params['refundment']) ? intval($params['refundment']) : 0, - 'business_type' => isset($params['business_type']) ? intval($params['business_type']) : 0, + 'business_type' => isset($params['business_type']) ? trim($params['business_type']) : 0, 'return_params' => empty($params['return_params']) ? '' : json_encode($params['return_params'], JSON_UNESCAPED_UNICODE), 'add_time' => time(), ]; @@ -98,7 +98,6 @@ class RefundLogService $data = Db::name('RefundLog')->where($where)->field($field)->limit($m, $n)->order($order_by)->select(); if(!empty($data)) { - $business_type_list = lang('common_business_type_list'); $refundment_list = lang('common_order_aftersale_refundment_list'); foreach($data as &$v) { @@ -111,9 +110,6 @@ class RefundLogService } } - // 业务类型 - $v['business_type_text'] = $business_type_list[$v['business_type']]['name']; - // 退款方式 $v['refundment_text'] = $refundment_list[$v['refundment']]['name']; -- GitLab