Commit 9fb73e35 authored by wanjilong's avatar wanjilong

add: 梳理报错信息及文案

parent ac188e65
......@@ -13,5 +13,7 @@ class FundsException extends BaseException
protected $cus = [
0 => '系统异常请联系管理员',
1 => '缺少渠道平台账户配置,请联系管理员!',
2 => 'Funds日志已经存在,请勿重复操作!',
3 => '营销账户不存在,请联系管理员!',
];
}
......@@ -18,23 +18,24 @@ class PayException extends BaseException
4 => '请确认订单信息及用户是否一致。',
5 => '订单缺少过期时间,请联系管理员',
6 => '订单过期,不允许支付',
7 => '支付订单创建失败,请管理员关注',
8 => '订单已经支付,请勿重复支付',
9 => '获取商户账户ID失败,请联系管理员',
10 => '回调失败,支付订单不存在',
11 => '回调失败,支付金额错误',
12 => '订单服务优惠信息错误',
13 => '订单明细保存失败',
10 => '未支付订单不允许核销,请管理员关注',
11 => '商家仅允许核销自己的订单,请管理员关注',
12 => '支付订单预结算失败,结算资金不能负数,请核对配置',
14 => '订单缺少商品信息,请联系管理员',
15 => '订单存在过期商品,不能支付',
18 => '订单不存在,请重试',
7 => '支付订单创建失败,请重试',
8 => '支付子订单创建失败,请重试',
9 => '订单优惠信息保存失败,请重试',
10 => '营销补贴锁定失败,请重试',
11 => '订单已支付,请勿重复支付',
12 => '支付订单不存在,请管理员关注',
13 => '支付回调金额不符,请管理员关注',
14 => '支付清分失败,结算资金为负',
15 => '支付回调资金入账失败,请管理员关注',
16 => '支付回调营销扣款失败,请管理员关注',
17 => '保存清分记录失败,请管理员关注',
18 => '保存清分明细记录失败,请管理员关注',
19 => '支付子单不存在,请管理员关注',
20 => '待核销子单处理中,请勿重复提交',
21 => '保存核销单失败,请重试',
22 => '保存核销子单失败,请重试',
23 => '保存核销结算失败,请重试',
24 => '更新子单结算状态失败,请管理员关注',
100=>'支付渠道错误,暂不支持该渠道',
101=>'该订单已经支付,请稍后刷新',
......
......@@ -16,11 +16,13 @@ class RefundException extends BaseException
2 => '订单未支付或不存在,请核对。',
3 => '不存在满足条件的退款订单。',
4 => '退单保存失败,请联系管理员。',
5 => '订单退款回调处理失败,请核对。',
6 => 'pingxx退单缺少matadata!',
7 => 'pingxx未支付订单不允许退款。',
8 => 'pingxx订单可能存在多次成功支付,需人工确认处理。',
5 => '退单子单保存失败,请联系管理员。',
6 => '支付子单状态更新失败,请联系管理员。',
7 => '退单保存失败,请联系管理员。',
8 => '退单更新失败,请联系管理员。',
9 => '保存退款结算信息失败,请重试',
10 => 'pingxx未支付订单不允许退款。',
11 => 'pingxx订单可能存在多次成功支付,需人工确认处理。',
];
}
......@@ -70,11 +70,18 @@ class OrderController extends Base
public function write_offAction() {
$params = $this->params;
$life_account_id = $params['life_account_id'];
$order_item_id = $params['order_item_id'];
$order_id = $params['order_id'];
if(!empty($params['order_item_id'])) {
if(!is_array($params['order_item_id'])) {
$params['order_item_id'] = explode(',', $params['order_item_id']);
}
} else {
$params['order_item_id'] = [];
}
$refundSrv = new PayService();
$ret = $refundSrv->write_off($order_item_id, $life_account_id);
$ret = $refundSrv->write_off($order_id, $params['order_item_id']);
$this->success(['result'=>$ret]);
}
......
......@@ -4,6 +4,7 @@
namespace App\Services\marketing;
use App\Exception\custom\FundsException;
use App\Models\order\mysql\MarketingAccount;
use App\Models\order\mysql\MarketingAccountLog;
use App\Models\order\mysql\MarketingAccountMap;
......@@ -23,7 +24,6 @@ class AccountService
$coupon = self::formatData($list);
$cnt = true;
foreach ($coupon as $id=>$amount) {
$marketing_account_id = self::map($id);
......@@ -182,6 +182,10 @@ class AccountService
}
}
if(empty(self::$maps[$third_id])) {
throw new FundsException(['cus'=>3]);
}
return self::$maps[$third_id];
}
......
......@@ -25,6 +25,11 @@ class FundsService
throw new FundsException(['cus' => 1]);
}
$log = PlatformFundsLog::getMaster('*', ['trade_id'=>$data['trade_id']]);
if($log) {
throw new FundsException(['cus' => 2]);
}
$cnt = PlatformFunds::update([
'total_amount[+]'=>$data['amount'],
'total_tip[+]'=>$data['tip'],
......@@ -58,6 +63,11 @@ class FundsService
throw new FundsException(['cus'=>1]);
}
$log = PlatformFundsLog::getMaster('*', ['trade_id'=>$data['trade_id']]);
if($log) {
throw new FundsException(['cus' => 2]);
}
$cnt = true;
$cnt = $cnt && PlatformFunds::update([
'total_amount[-]'=>$data['amount'],
......@@ -66,8 +76,8 @@ class FundsService
$cnt = $cnt && PlatformFundsLog::insert([
'platform_funds_id'=>$info['platform_funds_id'],
'trade_id'=>$data['order_id'],
'third_order_id'=>$data['third_id'],
'trade_id'=>$data['trade_id'],
'third_order_id'=>$data['third_order_id'],
'fund_type'=>2,
'amount'=>$data['amount'],
'tip'=>$data['tip'],
......
This diff is collapsed.
......@@ -53,6 +53,7 @@ class RefundService
try{
$payer = Channel::getChannel($data['pay_order']['pay_channel']);
$ret = $payer->refund($data, $mata_data);
//$ret['data'] = 'ok';
if(!empty($ret["data"])) {
$edit = ['request_pingxx_success_time'=>date('Y-m-d H:i:s')];
RefundOrder::update($edit, ['refund_order_id'=>$data['refund_order']['refund_order_id']]);
......@@ -119,45 +120,59 @@ class RefundService
// 修改状态,锁定业务
$refund_order_id = $object['metadata']['refund_order_id'];
RefundOrder::beginTransaction();
$refund = RefundOrder::getMaster('*', ['refund_order_id'=>$refund_order_id]);
$cnt = true;
//营销退款处理
$coupons = PayCouponItem::selectMaster('*',
['order_item_id'=>$object['metadata']['order_item_id']]);
if($coupons) {
$cnt = $cnt && AccountService::refund($coupons, $refund_order_id);
}
//总账资金记账
$cnt = $cnt && FundsService::payOut([
'trade_id'=>$refund['refund_order_id'],
'third_order_id'=>$object['id'],
'amount'=>$refund['refund_amount'],
'tip'=>$refund['refund_wx_tip'],
], 1);
try{
RefundOrder::beginTransaction();
$refund = RefundOrder::getMaster('*', ['refund_order_id'=>$refund_order_id]);
$cnt = true;
//营销退款处理
$coupons = PayCouponItem::selectMaster('*',
['order_item_id'=>$object['metadata']['order_item_id']]);
if($coupons) {
$cnt = $cnt && AccountService::refund($coupons, $refund_order_id);
}
$edit = [
'refund_order_status'=>2, //pingxx回调成功,
'pingxx_callback_success_time'=>date('Y-m-d H:i:s'), //回调成功时间
];
//总账资金记账
$cnt = $cnt && FundsService::payOut([
'trade_id'=>$refund['refund_order_id'],
'third_order_id'=>$object['id'],
'amount'=>$refund['refund_amount'],
'tip'=>$refund['refund_wx_tip'],
], 1);
if($cnt == false) {
throw new RefundException(['cus'=>7]);
}
$cnt = $cnt && RefundOrder::update($edit, ['refund_order_id'=>$refund_order_id, 'refund_order_status'=>1]);
$edit = [
'refund_order_status'=>2, //pingxx回调成功,
'pingxx_callback_success_time'=>date('Y-m-d H:i:s'), //回调成功时间
];
$cnt = $cnt && RefundOrder::update($edit, ['refund_order_id'=>$refund_order_id, 'refund_order_status'=>1]);
if($cnt == false) {
throw new RefundException(['cus'=>8]);
}
$cnt = $cnt && PayOrderItem::update(['refund_order_status'=>2], [
'order_item_id'=>$object['metadata']['order_item_id']
]);
$cnt = $cnt && PayOrderItem::update(['refund_order_status'=>2], [
'order_item_id'=>$object['metadata']['order_item_id']
]);
if($cnt == false) {
throw new RefundException(['cus'=>6]);
}
$cnt = $cnt && $this->refund_clear_record($refund, $object['metadata']['order_item_id']);
$cnt = $cnt && $this->refund_clear_record($refund, $object['metadata']['order_item_id']);
if($cnt == false) {
throw new RefundException(['cus'=>9]);
}
if($cnt) {
RefundOrder::commit();
return ['refund_order_id'=>$refund_order_id];
} else {
}catch (BaseException $e) {
RefundOrder::rollback();
throw new RefundException(['cus' => 16]);
throw $e;
}catch (\Exception $e) {
RefundOrder::rollback();
throw new BaseException(['msg'=>$e->getMessage(), 'code'=>2031]);
}
}
......@@ -175,7 +190,7 @@ class RefundService
$d = $m = $p = [];
foreach ($clear_items as $r) {
if($r['pay_sub_type'] == 404) { // 团长佣金收入
if($r['pay_sub_type'] == 105) { // 团长佣金收入
if(!isset($d[$r['account_id']])) {
$d[$r['account_id']] = [
'refund_personal_id'=>array_shift($ids),
......@@ -188,7 +203,7 @@ class RefundService
}
$d[$r['account_id']]['payment'] += $r['pay_amount'];
} elseif ($r['pay_sub_type'] == 405 || $r['pay_sub_type'] == 408) { // 平台抽成
} elseif ($r['pay_sub_type'] == 101 || $r['pay_sub_type'] == 108) { // 平台抽成
if(!isset($p[$r['account_id']])) {
$p[$r['account_id']] = [
'refund_platform_id'=>array_shift($ids),
......@@ -201,7 +216,7 @@ class RefundService
}
$p[$r['account_id']]['payment'] += $r['pay_amount'];
} elseif ($r['pay_sub_type'] == 407) { // 商品交易
} elseif ($r['pay_sub_type'] == 102) { // 商品交易
if(!isset($m[$r['account_id']])) {
$m[$r['account_id']] = [
'refund_merchant_id'=>array_shift($ids),
......@@ -252,20 +267,23 @@ class RefundService
throw new RefundException(['cus' => 2]);
}
$items = $exists = [];
$pay_order_items = PayOrderItem::selectMaster('*', ['pay_order_id'=>$pay_order['pay_order_id']]);
foreach ($pay_order_items as $item) {
if(!empty($order_item_ids) && !in_array($item['order_item_id'], $order_item_ids)) {
continue; //部分退款,且不再退款子单列表,不处理
}
if($item['can_notify_account'] == 1) {
continue; //已结算不允许退款
}
if(in_array($item['refund_order_status'], [1, 2])) {
$exists[] = $item['order_item_id'];
continue; //退款中、已退款不允许再次申请
}
if(!empty($order_item_ids) && !in_array($item['order_item_id'], $order_item_ids)) {
continue; //部分退款,且不再退款子单列表,不处理
}
$items[] = $item;
$refund_payment += $item['payment'];
}
......@@ -292,7 +310,7 @@ class RefundService
$wx_clear = PayOrderClearing::getMaster('*', [
'order_id'=>$pay_order['order_id'],
'pay_order_id'=>$pay_order['pay_order_id'],
'pay_sub_type'=>406 //三方渠道手续费
'pay_sub_type'=>106 //三方渠道手续费
]
);
$wx_total_tip = 0;
......@@ -326,25 +344,35 @@ class RefundService
$cnt = true;
$cnt = $cnt && RefundOrder::insert($refund, ['rowCount'=>true]);
if($cnt == false) {
throw new RefundException(['cus' => 4]);
}
$cnt = $cnt && RefundOrderItem::insert($refund_items, ['rowCount'=>true]);
$cnt = $cnt && PayOrderItem::update(['refund_order_status'=>1], ['order_item_id'=>array_column($items, 'order_item_id')]);
if($cnt == false) {
throw new RefundException(['cus' => 5]);
}
$cnt = $cnt && PayOrderItem::update(['refund_order_status'=>1], ['order_item_id'=>array_column($items, 'order_item_id')]);
if($cnt == false) {
throw new RefundException(['cus' => 4]);
throw new RefundException(['cus' => 6]);
}
RefundOrder::commit();
return [
'refund_order'=>$refund,
'pay_order'=>$pay_order,
'order_item_id'=>array_column($items, 'order_item_id'),
'exists'=>$exists,
];
}catch (\Exception $e) {
RefundOrder::rollback();
throw new BaseException(['msg'=>$e->getMessage(), 'code'=>$e->getCode()]);
}
return [
'refund_order'=>$refund,
'pay_order'=>$pay_order,
'order_item_id'=>array_column($items, 'order_item_id'),
];
}
private function get_idgen_id($number, $count = 1)
......
......@@ -7,11 +7,10 @@ update pay_order set pay_discount = 0;
-- 核销/确认收货表
CREATE TABLE `write_off_order` (
`write_off_order_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'ID',
`writeoff_order_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'ID',
`user_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT 'buyerId',
`order_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '订单id',
`write_off_status` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '核销状态,0 未核销, 1待确认 , 2 已核销',
`write_off_amount` int unsigned NOT NULL DEFAULT '0' COMMENT '核销金额,单位分',
`writeoff_status` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '核销状态,0 未核销, 1待确认 , 2 已核销',
`notify_account_status` tinyint NOT NULL DEFAULT '0' COMMENT '通知账户系统状态,0未通知,1已通知',
`notify_account_success_time` timestamp NULL DEFAULT NULL COMMENT '通知账户系统成功时间',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment