Merge branch 'dev'
This commit is contained in:
commit
c2fdcd6d8b
@ -19,6 +19,7 @@ use App\Services\OrderProductService;
|
|||||||
use App\Services\OrderService;
|
use App\Services\OrderService;
|
||||||
use App\Utils\Log;
|
use App\Utils\Log;
|
||||||
use App\Utils\Utils;
|
use App\Utils\Utils;
|
||||||
|
use Extend\Wechat\WechatPay;
|
||||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||||
use Hyperf\Amqp\Result;
|
use Hyperf\Amqp\Result;
|
||||||
@ -96,6 +97,18 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
|||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关闭支付订单
|
||||||
|
try {
|
||||||
|
$WechatPay = new WechatPay("1", 1);
|
||||||
|
|
||||||
|
// 关闭订单
|
||||||
|
$WechatPay->closeOrder($data['order_no']);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
Log::getInstance("queue-CancelUnpayOrders")->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
Log::getInstance("queue-CancelUnpayOrders")->info("成功");
|
Log::getInstance("queue-CancelUnpayOrders")->info("成功");
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
|
|||||||
@ -323,7 +323,6 @@ class Order extends Model
|
|||||||
->where($params)
|
->where($params)
|
||||||
->whereIn('order_type',[1,4,5]);
|
->whereIn('order_type',[1,4,5]);
|
||||||
|
|
||||||
// 问诊订单
|
|
||||||
$query = $query->where(function ($query) use ($is_platform_deep_cooperation){
|
$query = $query->where(function ($query) use ($is_platform_deep_cooperation){
|
||||||
$query->whereExists(function ($subQuery) use ($is_platform_deep_cooperation){
|
$query->whereExists(function ($subQuery) use ($is_platform_deep_cooperation){
|
||||||
$subQuery->from('order_inquiry');
|
$subQuery->from('order_inquiry');
|
||||||
|
|||||||
@ -306,6 +306,45 @@ class DoctorAccountService extends BaseService
|
|||||||
$amount_total = floor($doctor_account['balance_account'] * 100) / 100;
|
$amount_total = floor($doctor_account['balance_account'] * 100) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取可提现订单列表
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$params['is_withdrawal'] = 0;
|
||||||
|
|
||||||
|
$orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation']);
|
||||||
|
if (empty($orders)){
|
||||||
|
// 无订单,账户余额强制赋0;
|
||||||
|
$amount_total = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$OrderService = new OrderService();
|
||||||
|
|
||||||
|
// 可提现金额
|
||||||
|
$expected_amount_total = 0;
|
||||||
|
|
||||||
|
// 订单号数据
|
||||||
|
$order_nos = [];
|
||||||
|
|
||||||
|
foreach ($orders as $order){
|
||||||
|
// 获取订单退款金额
|
||||||
|
$refund_total = $OrderService->getOrderRefundAmount($order['order_no']);
|
||||||
|
|
||||||
|
// 获取订单可提现金额
|
||||||
|
$expected_amount_total = bcadd(
|
||||||
|
$expected_amount_total,
|
||||||
|
$OrderService->getOrderWithdrawalAmount($order,$refund_total),
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
$order_nos[] = $order['order_no'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对比订单金额和账户金额;金额相差1元及以上返回错误
|
||||||
|
$diff_amount_total = abs($amount_total - $expected_amount_total);
|
||||||
|
if ($diff_amount_total >= 1){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "提现金额错误");
|
||||||
|
}
|
||||||
|
|
||||||
/* // 获取可提现订单列表
|
/* // 获取可提现订单列表
|
||||||
$orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*']);
|
$orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*']);
|
||||||
if (empty($orders)){
|
if (empty($orders)){
|
||||||
@ -353,6 +392,7 @@ class DoctorAccountService extends BaseService
|
|||||||
$result['amount_total'] = $amount_total; // 账户余额
|
$result['amount_total'] = $amount_total; // 账户余额
|
||||||
$result['withdrawal_amount'] = $withdrawal_amount; // 提现金额
|
$result['withdrawal_amount'] = $withdrawal_amount; // 提现金额
|
||||||
$result['income_tax'] = $income_tax; // 个人所得税
|
$result['income_tax'] = $income_tax; // 个人所得税
|
||||||
|
$result['order_nos'] = $order_nos; // 可提现订单号
|
||||||
|
|
||||||
return success($result);
|
return success($result);
|
||||||
}
|
}
|
||||||
@ -625,7 +665,7 @@ class DoctorAccountService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 验证订单状态
|
// 验证订单状态
|
||||||
if ($order_service_package['order_service_status'] != 4 || $order_service_package['order_service_status'] != 5) {
|
if ($order_service_package['order_service_status'] != 4 && $order_service_package['order_service_status'] != 5) {
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "提现失败");
|
return fail(HttpEnumCode::HTTP_ERROR, "提现失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,6 +695,21 @@ class DoctorAccountService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 计算本次问诊服务包问诊金额
|
// 计算本次问诊服务包问诊金额
|
||||||
|
if ($order['order_type'] == 4){
|
||||||
|
// 随访包
|
||||||
|
$amount_total = bcadd(
|
||||||
|
(string)$amount_total,
|
||||||
|
bcsub(
|
||||||
|
(string)$order_service_package_detail['service_price'],
|
||||||
|
$refund_total,
|
||||||
|
3
|
||||||
|
),
|
||||||
|
3
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order['order_type'] == 5){
|
||||||
|
// 健康包
|
||||||
$amount_total = bcadd(
|
$amount_total = bcadd(
|
||||||
(string)$amount_total,
|
(string)$amount_total,
|
||||||
bcsub(
|
bcsub(
|
||||||
@ -670,6 +725,7 @@ class DoctorAccountService extends BaseService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 提现金额
|
// 提现金额
|
||||||
$amount_total = bcmul((string)$amount_total,"0.75",2);
|
$amount_total = bcmul((string)$amount_total,"0.75",2);
|
||||||
@ -758,6 +814,18 @@ class DoctorAccountService extends BaseService
|
|||||||
$data['withdrawal_id'] = $doctor_withdrawal['withdrawal_id'];
|
$data['withdrawal_id'] = $doctor_withdrawal['withdrawal_id'];
|
||||||
$data['doctor_id'] = $user_info['client_user_id'];
|
$data['doctor_id'] = $user_info['client_user_id'];
|
||||||
$data['order_id'] = $order['order_id'];
|
$data['order_id'] = $order['order_id'];
|
||||||
|
if ($order['order_type'] == 1){
|
||||||
|
// 问诊订单
|
||||||
|
$params = array();
|
||||||
|
$params['order_id'] = $order['order_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)){
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "提现失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
}
|
||||||
$doctor_withdrawal_order = DoctorWithdrawalOrder::addDoctorWithdrawalOrder($data);
|
$doctor_withdrawal_order = DoctorWithdrawalOrder::addDoctorWithdrawalOrder($data);
|
||||||
if (empty($doctor_withdrawal_order)) {
|
if (empty($doctor_withdrawal_order)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
|
|||||||
@ -1068,7 +1068,7 @@ class OrderService extends BaseService
|
|||||||
|
|
||||||
// 获取订单退款数据
|
// 获取订单退款数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['refund_no'] = $order_no;
|
$params['order_no'] = $order_no;
|
||||||
$order_refunds = OrderRefund::getList($params);
|
$order_refunds = OrderRefund::getList($params);
|
||||||
if (!empty($order_refunds)) {
|
if (!empty($order_refunds)) {
|
||||||
foreach ($order_refunds as $order_refund) {
|
foreach ($order_refunds as $order_refund) {
|
||||||
|
|||||||
@ -447,9 +447,9 @@ class OrderServicePackageService extends BaseService
|
|||||||
return fail(HttpEnumCode::HTTP_ERROR, "订单创建失败");
|
return fail(HttpEnumCode::HTTP_ERROR, "订单创建失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\Hyperf\Config\config("app_env") == "dev"){
|
// if (\Hyperf\Config\config("app_env") == "dev"){
|
||||||
$service_price = 1;
|
// $service_price = 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
|
|
||||||
|
|||||||
@ -769,8 +769,6 @@ class PatientOrderService extends BaseService
|
|||||||
/**
|
/**
|
||||||
* 获取患者订单支付数据
|
* 获取患者订单支付数据
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
|
||||||
* @throws NotFoundExceptionInterface
|
|
||||||
*/
|
*/
|
||||||
public function getPatientOrderPayInfo(): array
|
public function getPatientOrderPayInfo(): array
|
||||||
{
|
{
|
||||||
@ -854,6 +852,7 @@ class PatientOrderService extends BaseService
|
|||||||
$result['discount_amount'] = 0; // 优惠金额
|
$result['discount_amount'] = 0; // 优惠金额
|
||||||
|
|
||||||
if ($order_inquiry['payment_amount_total'] > 0) {
|
if ($order_inquiry['payment_amount_total'] > 0) {
|
||||||
|
try {
|
||||||
// 发起支付
|
// 发起支付
|
||||||
$WechatPay = new WechatPay(1, 1);
|
$WechatPay = new WechatPay(1, 1);
|
||||||
|
|
||||||
@ -865,6 +864,10 @@ class PatientOrderService extends BaseService
|
|||||||
|
|
||||||
// 获取小程序支付配置
|
// 获取小程序支付配置
|
||||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -966,6 +969,7 @@ class PatientOrderService extends BaseService
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($order_product['payment_amount_total'] > 0) {
|
if ($order_product['payment_amount_total'] > 0) {
|
||||||
|
try {
|
||||||
// 发起支付
|
// 发起支付
|
||||||
$WechatPay = new WechatPay(1, 2);
|
$WechatPay = new WechatPay(1, 2);
|
||||||
|
|
||||||
@ -977,6 +981,9 @@ class PatientOrderService extends BaseService
|
|||||||
|
|
||||||
// 获取小程序支付配置
|
// 获取小程序支付配置
|
||||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,6 +1042,7 @@ class PatientOrderService extends BaseService
|
|||||||
$result['discount_amount'] = 0;
|
$result['discount_amount'] = 0;
|
||||||
|
|
||||||
if ($order_detection['payment_amount_total'] > 0) {
|
if ($order_detection['payment_amount_total'] > 0) {
|
||||||
|
try {
|
||||||
// 发起支付
|
// 发起支付
|
||||||
$WechatPay = new WechatPay(1, 3);
|
$WechatPay = new WechatPay(1, 3);
|
||||||
|
|
||||||
@ -1046,6 +1054,9 @@ class PatientOrderService extends BaseService
|
|||||||
|
|
||||||
// 获取小程序支付配置
|
// 获取小程序支付配置
|
||||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1148,6 +1159,7 @@ class PatientOrderService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($order_service_package['payment_amount_total'] > 0) {
|
if ($order_service_package['payment_amount_total'] > 0) {
|
||||||
|
try {
|
||||||
// 发起支付
|
// 发起支付
|
||||||
$WechatPay = new WechatPay(1, 4);
|
$WechatPay = new WechatPay(1, 4);
|
||||||
|
|
||||||
@ -1159,6 +1171,9 @@ class PatientOrderService extends BaseService
|
|||||||
|
|
||||||
// 获取小程序支付配置
|
// 获取小程序支付配置
|
||||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -250,4 +250,28 @@ class WechatPay
|
|||||||
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭订单
|
||||||
|
* @param string $out_trade_no 商户系统内部订单号
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function closeOrder(string $out_trade_no): void
|
||||||
|
{
|
||||||
|
$app = $this->createApp();
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
"mchid" => $this->pay_config['mch_id'], // <---- 商户号
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::getInstance()->info(json_encode($options,JSON_UNESCAPED_UNICODE));
|
||||||
|
try {
|
||||||
|
$url = "v3/pay/transactions/out-trade-no/" . $out_trade_no . "/close";
|
||||||
|
|
||||||
|
$app->getClient()->postJson($url, $options);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user