Commit 511353b3 authored by 万继龙's avatar 万继龙

Merge branch 'refund_wanjl_0818' into 'master'

Refund wanjl 0818

See merge request bp/pay!67
parents d03c6b68 c7abd980
...@@ -26,5 +26,8 @@ class RefundException extends BaseException ...@@ -26,5 +26,8 @@ class RefundException extends BaseException
11 => 'pingxx退单缺少matadata!', 11 => 'pingxx退单缺少matadata!',
12 => 'pingxx未支付订单不允许退款。', 12 => 'pingxx未支付订单不允许退款。',
13 => 'pingxx订单可能存在多次成功支付,需人工确认处理。', 13 => 'pingxx订单可能存在多次成功支付,需人工确认处理。',
14 => '不存在满足条件的退款订单。',
15 => '订单未支付或不存在,请核对。',
16 => '订单退款回调处理失败,请核对。',
]; ];
} }
...@@ -21,11 +21,12 @@ class PayOrderClearingItem extends MysqlBase ...@@ -21,11 +21,12 @@ class PayOrderClearingItem extends MysqlBase
return $ret; return $ret;
} }
/* /**/
$sql = "select sum(poci.`pay_amount`) as 'pay_amount', notify_account_status from pay_order_clearing_item poci $sql = "select sum(poci.`pay_amount`) as 'pay_amount', notify_account_status from pay_order_clearing_item poci
join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id` join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id`
where poci.pay_sub_type = 105 and poci.account_id = ? and poi.refund_order_status = 0 group by notify_account_status "; where poci.pay_sub_type = 105 and poci.account_id = ? and poi.refund_order_status = 0 group by notify_account_status ";
*/
/*
$sql = "select sum(poci.`pay_amount`) as 'pay_amount', $sql = "select sum(poci.`pay_amount`) as 'pay_amount',
notify_account_status from pay_order_clearing_item poci notify_account_status from pay_order_clearing_item poci
join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id` join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id`
...@@ -33,6 +34,7 @@ where ...@@ -33,6 +34,7 @@ where
not exists (select 1 from refund_order ro where ro.`order_item_id` = poci.`order_item_id`) and not exists (select 1 from refund_order ro where ro.`order_item_id` = poci.`order_item_id`) and
poci.pay_sub_type = 105 and poci.account_id = ? poci.pay_sub_type = 105 and poci.account_id = ?
group by notify_account_status "; group by notify_account_status ";
*/
/* /*
type=1: 该团长历史累计分销佣金收入总和 type=1: 该团长历史累计分销佣金收入总和
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
use App\Base\Base; use App\Base\Base;
use App\Exception\custom\PayException;
use App\Services\pay\PayService; use App\Services\pay\PayService;
use App\Services\refund\RefundService; use App\Services\refund\RefundService;
use Api\PhpUtils\Log\FileLog; use Api\PhpUtils\Log\FileLog;
...@@ -39,15 +40,25 @@ class OrderController extends Base ...@@ -39,15 +40,25 @@ class OrderController extends Base
public function refundAction() { public function refundAction() {
$params = $this->params; $params = $this->getRequest()->getPost();
$user_id = $params['user_id'];
$order_item_id = $params['order_item_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'] = [];
}
if(empty($params['order_id'])) {
throw new PayException(['cus' => 1]);
}
$refundSrv = new RefundService(); $refundSrv = new RefundService();
$ret = $refundSrv->do_refund($order_item_id, $user_id); $ret = $refundSrv->do_refund($params['order_id'], $params['order_item_id']);
$this->success(['result'=>$ret]); $this->success(['result'=>$ret]);
} }
public function write_offAction() { public function write_offAction() {
......
...@@ -46,7 +46,7 @@ class Hook extends \Yaf\Plugin_Abstract { ...@@ -46,7 +46,7 @@ class Hook extends \Yaf\Plugin_Abstract {
} }
public function preDispatch(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) { public function preDispatch(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) {
// application/json形式,仅处理$_POST, 不整合$_GET, $_REQUEST // application/json形式,仅处理$_POST, 不整合$_GET
if($request->isPost() if($request->isPost()
&& $request->getServer('CONTENT_TYPE') == 'application/json') { && $request->getServer('CONTENT_TYPE') == 'application/json') {
...@@ -57,10 +57,13 @@ class Hook extends \Yaf\Plugin_Abstract { ...@@ -57,10 +57,13 @@ class Hook extends \Yaf\Plugin_Abstract {
} }
$_POST = json_decode($jsonPost, true); $_POST = json_decode($jsonPost, true);
if(!is_array($_POST)) { if(!is_array($_POST)) {
$_POST = []; $_POST = [];
FileLog::error('bp-gateway', 'json decode error raw:' . $jsonPost); FileLog::error('bp-gateway', 'json decode error raw:' . $jsonPost);
} }
$_REQUEST = array_merge($_REQUEST, $_POST);
} }
} }
......
...@@ -265,20 +265,24 @@ class PayService ...@@ -265,20 +265,24 @@ class PayService
$title = ''; $title = '';
} }
try{ try{
//通知消息 //通知消息
$app_id = 'wx65e9ba99c333444f'; $app_id = 'wx65e9ba99c333444f';
$template_id = 'EzOH2ZpfW-eUdFf9gzjZTAv-Z9PFmKHNsQ0VOGvvN7c'; $template_id = 'EzOH2ZpfW-eUdFf9gzjZTAv-Z9PFmKHNsQ0VOGvvN7c';
$page_url = 'https://testwx.appgc.cn/%23/bpmp/ticket/my'; $page_url = \Yaf\Application::app()->getConfig()->get('wxApp.jw.order');
$type = 1; $type = 1;
$param = [ $query = [
$title, $title,
$pay_order['order_id'], $pay_order['order_id'],
round($pay_order['pay_amount'] / 100, 2), round($pay_order['pay_amount'] / 100, 2),
date('Y-m-d'), date('Y-m-d'),
]; ];
Msg::send($pay_order['user_id'], $app_id, $template_id, $page_url, $type, $param); if(isset($ret['result']['order_info']['business_from']) && $ret['result']['order_info']['business_from'] != 2) {
//接龙业务不发送消息
Msg::send($pay_order['user_id'], $app_id, $template_id, $page_url, $type, $query);
}
}catch (\Throwable $e) { }catch (\Throwable $e) {
; ;
...@@ -295,30 +299,32 @@ class PayService ...@@ -295,30 +299,32 @@ class PayService
*/ */
public function write_off($order_item_id, $life_account_id) public function write_off($order_item_id, $life_account_id)
{ {
$cnt = 0;
//锁定状态 //锁定状态
try{ try{
PayOrderItem::beginTransaction(); PayOrderItem::beginTransaction();
$cnt = PayOrderItem::update([
'notify_account_status' => 0,
'can_notify_account' => 1,
'can_notify_account_time' => date('Y-m-d H:i:s'),
], ['order_item_id' => $order_item_id, 'can_notify_account'=>0]);
$refund = RefundOrder::getMaster('*', ['order_item_id'=>$order_item_id]);
if(!empty($refund)) {
throw new PayException(['cus'=>9]);
}
$item = PayOrderItem::getMaster('*', ['order_item_id' => $order_item_id]); $item = PayOrderItem::getMaster('*', ['order_item_id' => $order_item_id]);
if(empty($item)) { if(empty($item)) {
throw new PayException(['cus'=>10]); throw new PayException(['cus'=>10]);
} }
if($item['refund_order_status'] != 0) {
throw new PayException(['cus'=>9]);
}
$pay_order = PayOrder::getMaster('*', ['pay_order_id'=>$item['pay_order_id']]); $pay_order = PayOrder::getMaster('*', ['pay_order_id'=>$item['pay_order_id']]);
if(empty($pay_order) || $pay_order['life_account_id'] != $life_account_id) { if(empty($pay_order) || $pay_order['life_account_id'] != $life_account_id) {
throw new PayException(['cus'=>11]); throw new PayException(['cus'=>11]);
} }
$cnt = PayOrderItem::update([
'notify_account_status' => 0,
'can_notify_account' => 1,
'can_notify_account_time' => date('Y-m-d H:i:s'),
], ['order_item_id' => $order_item_id, 'can_notify_account'=>0, 'refund_order_status'=>0]);
PayOrderItem::commit(); PayOrderItem::commit();
}catch (\Exception $e) { }catch (\Exception $e) {
PayOrderItem::rollback(); PayOrderItem::rollback();
...@@ -421,6 +427,7 @@ class PayService ...@@ -421,6 +427,7 @@ class PayService
'pay_order_id' => $this->pay_order['pay_order_id'], 'pay_order_id' => $this->pay_order['pay_order_id'],
'order_id' => $this->pay_order['order_id'], 'order_id' => $this->pay_order['order_id'],
'order_item_id' => $r['order_item_id'], 'order_item_id' => $r['order_item_id'],
'payment' => $r['payment'],
'user_id' => $this->pay_order['user_id'], 'user_id' => $this->pay_order['user_id'],
]; ];
} }
......
...@@ -39,12 +39,14 @@ dingTalk.keys[]="SEC0298ad3f80e16df12cd4d6f6c39e961b500e2ff486f4c4377c0e2af8f453 ...@@ -39,12 +39,14 @@ dingTalk.keys[]="SEC0298ad3f80e16df12cd4d6f6c39e961b500e2ff486f4c4377c0e2af8f453
[prod : common : exception : dingTalk] [prod : common : exception : dingTalk]
pingxx.appid = "app_9m1ubDG4e1mPXLCG" pingxx.appid = "app_9m1ubDG4e1mPXLCG"
wxApp.jw.order = "https://wx.appgc.cn/%23/bpmp/ticket/my"
[pref : common : exception : dingTalk] [pref : common : exception : dingTalk]
pingxx.appid = "app_9m1ubDG4e1mPXLCG" pingxx.appid = "app_9m1ubDG4e1mPXLCG"
[test : common : exception : dingTalk] [test : common : exception : dingTalk]
pingxx.appid = "app_W10Oe5XrvbzHfP4W" pingxx.appid = "app_W10Oe5XrvbzHfP4W"
wxApp.jw.order = "https://testwx.appgc.cn/%23/bpmp/ticket/my"
[dev : common : exception] [dev : common : exception]
pingxx.appid = "app_W10Oe5XrvbzHfP4W" pingxx.appid = "app_W10Oe5XrvbzHfP4W"
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