新增取消订单恢复优惠卷,新增获取订单支付数据接口
This commit is contained in:
parent
9fd87ac071
commit
53d9e2072d
@ -5,12 +5,15 @@ declare(strict_types=1);
|
|||||||
namespace App\Amqp\Consumer;
|
namespace App\Amqp\Consumer;
|
||||||
|
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
|
use App\Model\OrderInquiryCoupon;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
use App\Utils\Log;
|
use App\Utils\Log;
|
||||||
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;
|
||||||
use Hyperf\Amqp\Annotation\Consumer;
|
use Hyperf\Amqp\Annotation\Consumer;
|
||||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||||
use PhpAmqpLib\Message\AMQPMessage;
|
use PhpAmqpLib\Message\AMQPMessage;
|
||||||
use Hyperf\Amqp\Message\Type;
|
use Hyperf\Amqp\Message\Type;
|
||||||
@ -38,30 +41,36 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
|||||||
{
|
{
|
||||||
Log::getInstance()->error("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
Log::getInstance()->error("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 获取订单数据
|
// 获取订单数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
if (empty($order_inquiry)) {
|
if (empty($order_inquiry)) {
|
||||||
|
Db::rollBack();
|
||||||
Log::getInstance()->error("队列执行失败原因:未查询到对应订单数据");
|
Log::getInstance()->error("队列执行失败原因:未查询到对应订单数据");
|
||||||
return Result::DROP;// 销毁
|
return Result::DROP;// 销毁
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测订单状态
|
// 检测订单状态
|
||||||
if ($order_inquiry['inquiry_status'] != 1) {
|
if ($order_inquiry['inquiry_status'] != 1) {
|
||||||
|
Db::rollBack();
|
||||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
Log::getInstance()->error("队列执行失败原因:订单状态为" . $order_inquiry['inquiry_status'] . "无法执行");
|
Log::getInstance()->error("队列执行失败原因:订单状态为" . $order_inquiry['inquiry_status'] . "无法执行");
|
||||||
return Result::DROP;// 销毁
|
return Result::DROP;// 销毁
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
||||||
|
Db::rollBack();
|
||||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||||
Log::getInstance()->error("队列执行失败原因:订单正在退款中");
|
Log::getInstance()->error("队列执行失败原因:订单正在退款中");
|
||||||
return Result::DROP;// 销毁
|
return Result::DROP;// 销毁
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($order_inquiry['inquiry_pay_status'] == 2) {
|
if ($order_inquiry['inquiry_pay_status'] == 2) {
|
||||||
|
Db::rollBack();
|
||||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
Log::getInstance()->error("队列执行失败原因:订单已支付");
|
Log::getInstance()->error("队列执行失败原因:订单已支付");
|
||||||
return Result::DROP;// 销毁
|
return Result::DROP;// 销毁
|
||||||
@ -69,6 +78,7 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
|||||||
|
|
||||||
// 检测订单删除状态
|
// 检测订单删除状态
|
||||||
if ($order_inquiry['is_delete'] == 1) {
|
if ($order_inquiry['is_delete'] == 1) {
|
||||||
|
Db::rollBack();
|
||||||
// 删除状态(0:否 1:是)
|
// 删除状态(0:否 1:是)
|
||||||
Log::getInstance()->error("取消未支付订单:订单已被删除");
|
Log::getInstance()->error("取消未支付订单:订单已被删除");
|
||||||
return Result::ACK;// 销毁
|
return Result::ACK;// 销毁
|
||||||
@ -86,9 +96,29 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
|||||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
OrderInquiry::edit($params,$data);
|
OrderInquiry::edit($params,$data);
|
||||||
|
|
||||||
|
// 处理订单优惠卷
|
||||||
|
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0){
|
||||||
|
// 获取用户优惠卷信息
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$order_inquiry_coupon = OrderInquiryCoupon::getOne($params);
|
||||||
|
if (!empty($order_inquiry_coupon)){
|
||||||
|
// 恢复优惠卷
|
||||||
|
$data = array();
|
||||||
|
$data['user_coupon_status'] = 0;
|
||||||
|
$data['coupon_use_date'] = date('Y-m-d H:i:s',time());
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
|
||||||
|
UserCoupon::edit($params,$data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
Log::getInstance()->error("取消未支付订单 队列执行成功");
|
Log::getInstance()->error("取消未支付订单 队列执行成功");
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
Db::rollBack();
|
||||||
Log::getInstance()->error("队列执行失败原因:" . $e->getMessage());
|
Log::getInstance()->error("队列执行失败原因:" . $e->getMessage());
|
||||||
return Result::REQUEUE; // 重回队列
|
return Result::REQUEUE; // 重回队列
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,9 @@ use App\Constants\HttpEnumCode;
|
|||||||
use App\Exception\BusinessException;
|
use App\Exception\BusinessException;
|
||||||
use App\Model\Hospital;
|
use App\Model\Hospital;
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
|
use App\Model\OrderInquiryCoupon;
|
||||||
use App\Model\OrderInquiryRefund;
|
use App\Model\OrderInquiryRefund;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
|
|||||||
@ -125,4 +125,20 @@ class PatientOrderController extends AbstractController
|
|||||||
$data = $PatientOrderService->deletePatientProductOrder();
|
$data = $PatientOrderService->deletePatientProductOrder();
|
||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取患者订单支付数据
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function getPatientOrderPayInfo(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(PatientOrderRequest::class);
|
||||||
|
$request->scene('getPatientOrderPayInfo')->validateResolved();
|
||||||
|
|
||||||
|
$PatientOrderService = new PatientOrderService();
|
||||||
|
$data = $PatientOrderService->getPatientOrderPayInfo();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -221,5 +221,6 @@ class UserController extends AbstractController
|
|||||||
// $imService->addRecentContactRecordCache("491925054779883520", 2, 10004, $data);
|
// $imService->addRecentContactRecordCache("491925054779883520", 2, 10004, $data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,22 +12,22 @@ use Hyperf\Database\Query\Builder;
|
|||||||
use Hyperf\Snowflake\Concern\Snowflake;
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $order_inquiry_id 主键id
|
* @property int $order_inquiry_id 主键id
|
||||||
* @property string $user_id 用户id-患者
|
* @property int $user_id 用户id-患者
|
||||||
* @property string $patient_id 患者id
|
* @property int $patient_id 患者id
|
||||||
* @property string $doctor_id 医生id(未分配时为null)
|
* @property int $doctor_id 医生id(未分配时为null)
|
||||||
* @property string $family_id 家庭成员id(就诊用户)
|
* @property int $family_id 家庭成员id(就诊用户)
|
||||||
* @property int $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
* @property int $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||||
* @property int $inquiry_mode 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
* @property int $inquiry_mode 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||||
* @property int $inquiry_status 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
* @property int $inquiry_status 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
* @property int $is_delete 删除状态(0:否 1:是)
|
* @property int $is_delete 删除状态(0:否 1:是)
|
||||||
* @property int $inquiry_refund_status 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
* @property int $inquiry_refund_status 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||||
* @property string $inquiry_refund_no 系统退款单号
|
|
||||||
* @property int $inquiry_pay_channel 支付渠道(1:小程序支付 2:微信扫码支付)
|
* @property int $inquiry_pay_channel 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||||
* @property int $inquiry_pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
* @property int $inquiry_pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
* @property int $inquiry_no 系统订单编号
|
* @property string $inquiry_no 系统订单编号
|
||||||
* @property string $escrow_trade_no 第三方支付流水号
|
* @property string $escrow_trade_no 第三方支付流水号
|
||||||
* @property string $amount_total 订单金额
|
* @property string $amount_total 订单金额
|
||||||
|
* @property string $coupon_amount_total 优惠卷总金额
|
||||||
* @property string $payment_amount_total 实际付款金额
|
* @property string $payment_amount_total 实际付款金额
|
||||||
* @property string $pay_time 支付时间
|
* @property string $pay_time 支付时间
|
||||||
* @property string $reception_time 接诊时间(已接诊)
|
* @property string $reception_time 接诊时间(已接诊)
|
||||||
@ -45,6 +45,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $patient_age 患者年龄-就诊人
|
* @property int $patient_age 患者年龄-就诊人
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
|
* @property-read OrderInquiryCase $OrderInquiryCase
|
||||||
* @property-read UserDoctor $UserDoctor
|
* @property-read UserDoctor $UserDoctor
|
||||||
*/
|
*/
|
||||||
class OrderInquiry extends Model
|
class OrderInquiry extends Model
|
||||||
@ -59,7 +60,7 @@ class OrderInquiry extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['order_inquiry_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'inquiry_type', 'inquiry_mode', 'inquiry_status', 'is_delete', 'inquiry_refund_status', 'inquiry_refund_no', 'inquiry_pay_channel', 'inquiry_pay_status', 'inquiry_no', 'escrow_trade_no', 'amount_total', 'payment_amount_total', 'pay_time', 'reception_time', 'complete_time', 'finish_time', 'settlement_amount_total', 'settlement_status', 'settlement_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
protected array $fillable = ['order_inquiry_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'inquiry_type', 'inquiry_mode', 'inquiry_status', 'is_delete', 'inquiry_refund_status', 'inquiry_pay_channel', 'inquiry_pay_status', 'inquiry_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'reception_time', 'complete_time', 'finish_time', 'settlement_amount_total', 'settlement_status', 'settlement_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "order_inquiry_id";
|
protected string $primaryKey = "order_inquiry_id";
|
||||||
|
|
||||||
|
|||||||
@ -105,4 +105,15 @@ class UserCoupon extends Model
|
|||||||
{
|
{
|
||||||
return self::create($data);
|
return self::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param array $params
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function edit(array $params = [], array $data = []): int
|
||||||
|
{
|
||||||
|
return self::where($params)->update($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,10 @@ class PatientOrderRequest extends FormRequest
|
|||||||
'order_product_status',// 订单状态(0:全部 1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
'order_product_status',// 订单状态(0:全部 1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||||
'family_id',// 家庭成员id(就诊用户)
|
'family_id',// 家庭成员id(就诊用户)
|
||||||
],
|
],
|
||||||
|
'getPatientOrderPayInfo' => [ // 获取患者订单支付数据
|
||||||
|
"order_type", // 订单类型(1:问诊订单 2:药品订单)
|
||||||
|
"order_no"// 订单编号
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +57,9 @@ class PatientOrderRequest extends FormRequest
|
|||||||
'reply_progress' => 'required|integer|min:0|max:5',//
|
'reply_progress' => 'required|integer|min:0|max:5',//
|
||||||
|
|
||||||
'inquiry_status' => 'required|integer|min:0|max:4',
|
'inquiry_status' => 'required|integer|min:0|max:4',
|
||||||
|
|
||||||
|
'order_type' => 'required|integer|min:1|max:2',
|
||||||
|
'order_no' => 'required',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +101,12 @@ class PatientOrderRequest extends FormRequest
|
|||||||
'inquiry_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'inquiry_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
|
||||||
|
'order_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'order_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'order_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'order_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'order_no.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ use App\Model\PatientFamily;
|
|||||||
use App\Model\PatientFamilyHealth;
|
use App\Model\PatientFamilyHealth;
|
||||||
use App\Model\PatientFamilyPersonal;
|
use App\Model\PatientFamilyPersonal;
|
||||||
use App\Model\Product;
|
use App\Model\Product;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
use App\Utils\Mask;
|
use App\Utils\Mask;
|
||||||
@ -121,8 +122,8 @@ class InquiryService extends BaseService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 实际付款金额
|
// 实际付款金额
|
||||||
$coupon_price = $user_coupon['coupon']['coupon_price'] ?? 0;
|
$coupon_amount_total = $user_coupon['coupon']['coupon_price'] ?? 0;
|
||||||
$payment_amount_total = $inquiry_price - $coupon_price;
|
$payment_amount_total = $inquiry_price - $coupon_amount_total;
|
||||||
|
|
||||||
// 生成问诊订单
|
// 生成问诊订单
|
||||||
$data = array();
|
$data = array();
|
||||||
@ -136,6 +137,7 @@ class InquiryService extends BaseService
|
|||||||
$data['inquiry_pay_channel'] = $inquiry_pay_channel ?? 0;// 支付渠道(1:小程序支付 2:微信扫码支付)
|
$data['inquiry_pay_channel'] = $inquiry_pay_channel ?? 0;// 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||||
$data['inquiry_no'] = $generator->generate();// 订单编号
|
$data['inquiry_no'] = $generator->generate();// 订单编号
|
||||||
$data['amount_total'] = $inquiry_price;// 订单金额
|
$data['amount_total'] = $inquiry_price;// 订单金额
|
||||||
|
$data['coupon_amount_total'] = $coupon_amount_total;// 优惠卷总金额
|
||||||
$data['payment_amount_total'] = $payment_amount_total;// 实际付款金额
|
$data['payment_amount_total'] = $payment_amount_total;// 实际付款金额
|
||||||
$data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人
|
$data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人
|
||||||
$data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码)
|
$data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码)
|
||||||
@ -247,20 +249,17 @@ class InquiryService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发起支付
|
// 修改优惠卷使用状态
|
||||||
$WechatPay = new WechatPay(1);
|
if (!empty($user_coupon)){
|
||||||
|
$data = array();
|
||||||
|
$data['user_coupon_status'] = 1;
|
||||||
|
$data['coupon_use_date'] = date('Y-m-d H:i:s',time());
|
||||||
|
|
||||||
// 获取预支付交易会话标识
|
$params = array();
|
||||||
$total = $inquiry_price * 100;
|
$params['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||||
$prepay = $WechatPay->getJsapiPrepayId($order_inquiry['inquiry_no'], $total, $user_info['open_id']);
|
UserCoupon::edit($params,$data);
|
||||||
if (empty($prepay)) {
|
|
||||||
Db::rollBack();
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取小程序支付配置
|
|
||||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
|
||||||
|
|
||||||
// 增加至取消订单延迟队列
|
// 增加至取消订单延迟队列
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
@ -281,12 +280,8 @@ class InquiryService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['amount_total'] = $inquiry_price; // 订单金额
|
|
||||||
$result['inquiry_no'] = $order_inquiry['inquiry_no']; // 订单编号
|
$result['inquiry_no'] = $order_inquiry['inquiry_no']; // 订单编号
|
||||||
$result['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; // 订单主键id
|
$result['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; // 订单主键id
|
||||||
$result['created_at'] = date('Y-m-d H:i:s', strtotime($order_inquiry['created_at'])); // 创建时间
|
|
||||||
$result['inquiry_type'] = $order_inquiry['inquiry_type']; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
|
||||||
$result['pay_config'] = $pay_config; // 小程序支付配置
|
|
||||||
|
|
||||||
return success($result);
|
return success($result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use App\Model\OrderPrescription;
|
|||||||
use App\Model\OrderProduct;
|
use App\Model\OrderProduct;
|
||||||
use App\Model\OrderProductItem;
|
use App\Model\OrderProductItem;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
|
use Extend\Wechat\WechatPay;
|
||||||
use Hyperf\DbConnection\Db;
|
use Hyperf\DbConnection\Db;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@ -601,4 +602,103 @@ class PatientOrderService extends BaseService
|
|||||||
|
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取患者订单支付数据
|
||||||
|
* @return array
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function getPatientOrderPayInfo(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$order_type = $this->request->input('order_type');
|
||||||
|
$order_no = $this->request->input('order_no');
|
||||||
|
|
||||||
|
if ($order_type == 1){
|
||||||
|
// 问诊订单
|
||||||
|
$params = array();
|
||||||
|
$params['inquiry_no'] = $order_no;
|
||||||
|
$params['patient_id'] = $user_info['client_user_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"非法订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单状态
|
||||||
|
if ($order_inquiry['inquiry_status'] != 1){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"订单状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单支付状态
|
||||||
|
if ($order_inquiry['inquiry_pay_status'] != 1){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"订单支付状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
$order_id = $order_inquiry['order_inquiry_id'];
|
||||||
|
$created_at = $order_inquiry['created_at'];
|
||||||
|
$inquiry_type = $order_inquiry['inquiry_type'];
|
||||||
|
|
||||||
|
// 获取订单金额
|
||||||
|
$amount_total = $order_inquiry['amount_total'];
|
||||||
|
$payment_amount_total = $order_inquiry['payment_amount_total'];
|
||||||
|
$coupon_amount_total = $order_inquiry['coupon_amount_total'];
|
||||||
|
|
||||||
|
}elseif ($order_type == 2){
|
||||||
|
// 药品订单
|
||||||
|
$params = array();
|
||||||
|
$params['order_product_no'] = $order_no;
|
||||||
|
$params['patient_id'] = $user_info['client_user_id'];
|
||||||
|
$order_product = OrderProduct::getOne($params);
|
||||||
|
if (empty($order_product)){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"非法订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单状态
|
||||||
|
if ($order_product['order_product_status'] != 1){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"订单状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单支付状态
|
||||||
|
if ($order_product['inquiry_pay_status'] != 1){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"订单支付状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
$order_id = $order_product['order_product_id'];
|
||||||
|
$created_at = $order_product['created_at'];
|
||||||
|
$inquiry_type = 0;
|
||||||
|
|
||||||
|
// 获取订单金额
|
||||||
|
$amount_total = $order_product['amount_total'];
|
||||||
|
$payment_amount_total = $order_product['payment_amount_total'];
|
||||||
|
$coupon_amount_total = 0;
|
||||||
|
}else{
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起支付
|
||||||
|
$WechatPay = new WechatPay(1);
|
||||||
|
|
||||||
|
// 获取预支付交易会话标识
|
||||||
|
$prepay = $WechatPay->getJsapiPrepayId($order_no, $payment_amount_total * 100, $user_info['open_id']);
|
||||||
|
if (empty($prepay)) {
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取小程序支付配置
|
||||||
|
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
$result['amount_total'] = $amount_total; // 订单金额
|
||||||
|
$result['payment_amount_total'] = $payment_amount_total; // 实际订单金额
|
||||||
|
$result['coupon_amount_total'] = $coupon_amount_total; // 优惠金额
|
||||||
|
$result['order_no'] = $order_no; // 订单编号
|
||||||
|
$result['order_id'] = $order_id; // 订单主键id(问诊订单:order_inquiry_id 药品订单:order_product_id)
|
||||||
|
$result['created_at'] = $created_at; // 创建时间
|
||||||
|
$result['inquiry_type'] = $inquiry_type; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||||
|
$result['pay_config'] = $pay_config; // 小程序支付配置
|
||||||
|
|
||||||
|
return success($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -196,8 +196,6 @@ Router::addGroup('/patient', function () {
|
|||||||
// 创建问诊订单
|
// 创建问诊订单
|
||||||
Router::post('', [InquiryController::class, 'addInquiryOrder']);
|
Router::post('', [InquiryController::class, 'addInquiryOrder']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 检测是否可以接诊
|
// 检测是否可以接诊
|
||||||
Router::get('/check', [PatientDoctorController::class, 'getDoctorInquiryCheck']);
|
Router::get('/check', [PatientDoctorController::class, 'getDoctorInquiryCheck']);
|
||||||
|
|
||||||
@ -206,9 +204,6 @@ Router::addGroup('/patient', function () {
|
|||||||
|
|
||||||
// 新增问诊评价
|
// 新增问诊评价
|
||||||
Router::post('/evaluation', [InquiryController::class, 'addInquiryEvaluation']);
|
Router::post('/evaluation', [InquiryController::class, 'addInquiryEvaluation']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 医生数据
|
// 医生数据
|
||||||
@ -277,6 +272,7 @@ Router::addGroup('/patient', function () {
|
|||||||
Router::get('/last/{family_id:\d+}', [PatientCaseController::class, 'getLastCase']);
|
Router::get('/last/{family_id:\d+}', [PatientCaseController::class, 'getLastCase']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 订单
|
||||||
Router::addGroup('/order', function () {
|
Router::addGroup('/order', function () {
|
||||||
Router::addGroup('/inquiry', function () {
|
Router::addGroup('/inquiry', function () {
|
||||||
// 获取患者问诊订单列表
|
// 获取患者问诊订单列表
|
||||||
@ -309,8 +305,8 @@ Router::addGroup('/patient', function () {
|
|||||||
// 删除药品订单
|
// 删除药品订单
|
||||||
Router::delete('/{order_product_id:\d+}', [PatientOrderController::class, 'deletePatientProductOrder']);
|
Router::delete('/{order_product_id:\d+}', [PatientOrderController::class, 'deletePatientProductOrder']);
|
||||||
|
|
||||||
// 创建药品订单
|
// 创建药品订单-未开发
|
||||||
Router::post('/121212da', [PatientOrderController::class, 'imCallBack']);
|
Router::post('', [PatientOrderController::class, 'imCallBack']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处方订单
|
// 处方订单
|
||||||
@ -327,6 +323,9 @@ Router::addGroup('/patient', function () {
|
|||||||
// 删除处方订单记录-处方管理
|
// 删除处方订单记录-处方管理
|
||||||
Router::post('/18', [PatientOrderController::class, 'imCallBack']);
|
Router::post('/18', [PatientOrderController::class, 'imCallBack']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取患者订单支付数据
|
||||||
|
Router::get('/pay', [PatientOrderController::class, 'getPatientOrderPayInfo']);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user