Commit b84d1743 authored by 万继龙's avatar 万继龙

Merge branch 'master' into 'pay_wanjl_0830'

# Conflicts:
#   conf/application.ini
#   conf/cli.ini
add: merge ini
parents 3adb8e1c b734e336
......@@ -26,5 +26,8 @@ class RefundException extends BaseException
11 => 'pingxx退单缺少matadata!',
12 => 'pingxx未支付订单不允许退款。',
13 => 'pingxx订单可能存在多次成功支付,需人工确认处理。',
14 => '不存在满足条件的退款订单。',
15 => '订单未支付或不存在,请核对。',
16 => '订单退款回调处理失败,请核对。',
];
}
......@@ -2,6 +2,7 @@
namespace App\Models\order\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
use App\Exception\BaseException;
class PayOrderClearingItem extends MysqlBase
{
......@@ -20,10 +21,21 @@ class PayOrderClearingItem extends MysqlBase
return $ret;
}
/**/
$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`
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',
notify_account_status from pay_order_clearing_item poci
join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id`
where
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 = ?
group by notify_account_status ";
*/
/*
type=1: 该团长历史累计分销佣金收入总和
type=2: 该团长当前未结算分销佣金总和
......
......@@ -2,6 +2,7 @@
use App\Base\Base;
use App\Exception\custom\PayException;
use App\Services\pay\PayService;
use App\Services\refund\RefundService;
use Api\PhpUtils\Log\FileLog;
......@@ -39,15 +40,25 @@ class OrderController extends Base
public function refundAction() {
$params = $this->params;
$user_id = $params['user_id'];
$order_item_id = $params['order_item_id'];
$params = $this->getRequest()->getPost();
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();
$ret = $refundSrv->do_refund($order_item_id, $user_id);
$ret = $refundSrv->do_refund($params['order_id'], $params['order_item_id']);
$this->success(['result'=>$ret]);
}
public function chargesAction() {
......
......@@ -73,4 +73,13 @@ class TccController extends Base
$this->success(['result'=>[]]);
}
public function traceAction() {
$params = $this->getRequest()->getPost();
//$params['traceId'] = \Api\PhpUtils\Log\Tracer::getTraceId();
file_put_contents('/tmp/aa.log', json_encode($_SERVER), FILE_APPEND);
$params['traceId'] = \Helpers\Tracer::getTraceId();
$this->success($params);
}
}
......@@ -46,7 +46,7 @@ class Hook extends \Yaf\Plugin_Abstract {
}
public function preDispatch(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) {
// application/json形式,仅处理$_POST, 不整合$_GET, $_REQUEST
// application/json形式,仅处理$_POST, 不整合$_GET
if($request->isPost()
&& $request->getServer('CONTENT_TYPE') == 'application/json') {
......@@ -57,10 +57,13 @@ class Hook extends \Yaf\Plugin_Abstract {
}
$_POST = json_decode($jsonPost, true);
if(!is_array($_POST)) {
$_POST = [];
FileLog::error('bp-gateway', 'json decode error raw:' . $jsonPost);
}
$_REQUEST = array_merge($_REQUEST, $_POST);
}
}
......
......@@ -10,7 +10,6 @@ use App\Models\order\mysql\PayOrder;
use App\Models\order\mysql\PayOrderItem;
use App\Models\order\mysql\PayOrderClearing;
use App\Models\order\mysql\PayOrderClearingItem;
use App\Models\order\mysql\RefundOrder;
use App\Services\order\OrderService;
use App\Services\pingxx\PingxxService;
......@@ -65,6 +64,7 @@ class PayService
$metadata = [
'app_id'=>'merchant-c',
'pingxx_id'=>PingxxService::getInstance()->getAppId(),
'environ'=>Application::app()->environ(),
'order_id'=>$order_id,
'goods'=>[],
......@@ -113,6 +113,7 @@ class PayService
'expire_time' => date('Y-m-d H:i:s', $pay_expiration_time),
'source_name' => 10,
'service_name' => 1,
'business_from' => $order_info['business_from'],
'extra' => json_encode([]),
];
......@@ -285,20 +286,24 @@ class PayService
$title = '';
}
try{
//通知消息
$app_id = 'wx65e9ba99c333444f';
$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;
$param = [
$query = [
$title,
$pay_order['order_id'],
round($pay_order['pay_amount'] / 100, 2),
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) {
;
......@@ -373,30 +378,32 @@ class PayService
*/
public function write_off($order_item_id, $life_account_id)
{
$cnt = 0;
//锁定状态
try{
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]);
if(empty($item)) {
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']]);
if(empty($pay_order) || $pay_order['life_account_id'] != $life_account_id) {
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();
}catch (\Exception $e) {
PayOrderItem::rollback();
......@@ -499,6 +506,7 @@ class PayService
'pay_order_id' => $this->pay_order['pay_order_id'],
'order_id' => $this->pay_order['order_id'],
'order_item_id' => $r['order_item_id'],
'payment' => $r['payment'],
'user_id' => $this->pay_order['user_id'],
];
}
......
......@@ -33,6 +33,9 @@ class PingxxService
return self::$instance;
}
public function getAppId() {
return Pingpp::getAppId();
}
/**
* @param $order_item_id
......
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