1
This commit is contained in:
parent
7864a338e6
commit
813e29731b
@ -449,85 +449,85 @@ class CallBackController extends AbstractController
|
|||||||
Log::getInstance()->info("微信退款回调数据:" . json_encode($message->toArray(),JSON_UNESCAPED_UNICODE));
|
Log::getInstance()->info("微信退款回调数据:" . json_encode($message->toArray(),JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
if (empty($message['out_trade_no'])){
|
if (empty($message['out_trade_no'])){
|
||||||
Log::getInstance()->info("微信退款回调数据错误");
|
Log::getInstance()->info("药品微信退款回调数据处理失败,缺少外部订单号");
|
||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证订单数据
|
// 查询药品订单
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['inquiry_no'] = $message['out_trade_no'];
|
$params['order_product_no'] = $message['out_trade_no'];
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
$order_product = OrderProduct::getOne($params);
|
||||||
if (empty($order_inquiry)){
|
if (empty($order_product)){
|
||||||
Log::getInstance()->info("非法订单");
|
Db::rollBack();
|
||||||
|
Log::getInstance()->info("药品微信退款回调数据处理失败,无订单数据");
|
||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证订单状态
|
// 验证订单状态
|
||||||
if ($order_inquiry['inquiry_status'] == 1){
|
if ($order_product['order_product_status'] == 1){
|
||||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||||
Log::getInstance()->info("订单状态错误:当前为" . $order_inquiry['inquiry_status']);
|
Log::getInstance()->info("药品微信退款回调数据处理失败,订单状态错误:当前为" . $order_product['order_product_status']);
|
||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 验证订单退款状态
|
// 验证订单退款状态
|
||||||
if ($order_inquiry['inquiry_refund_status'] == 3) {
|
if ($order_product['refund_status'] == 3) {
|
||||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||||
Log::getInstance()->info("订单退款状态错误:当前为" . $order_inquiry['inquiry_refund_status']);
|
Log::getInstance()->info("药品微信退款回调数据处理失败,订单退款状态为" . $order_product['refund_status']);
|
||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证订单支付状态
|
// 验证订单支付状态
|
||||||
if (in_array($order_inquiry['inquiry_pay_status'],[1,3,4,5,6,7])) {
|
if (in_array($order_product['pay_status'],[1,3,4,5,6,7])) {
|
||||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
Log::getInstance()->error("队列执行失败原因:订单未支付");
|
Log::getInstance()->error("药品微信退款回调数据处理失败:订单未支付");
|
||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退款状态
|
// 退款状态
|
||||||
if ($message['refund_status'] == "SUCCESS"){
|
if ($message['refund_status'] == "SUCCESS"){
|
||||||
// 退款成功
|
// 退款成功
|
||||||
$inquiry_refund_status = 3;
|
$refund_status = 3;
|
||||||
}elseif ($message['refund_status'] == "CLOSED"){
|
}elseif ($message['refund_status'] == "CLOSED"){
|
||||||
// 退款关闭
|
// 退款关闭
|
||||||
$inquiry_refund_status = 5;
|
$refund_status = 5;
|
||||||
}elseif ($message['refund_status'] == "ABNORMAL"){
|
}elseif ($message['refund_status'] == "ABNORMAL"){
|
||||||
// 退款异常
|
// 退款异常
|
||||||
$inquiry_refund_status = 6;
|
$refund_status = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($inquiry_refund_status)){
|
if (empty($refund_status)){
|
||||||
// 错误,无退款状态
|
// 错误,无退款状态
|
||||||
Log::getInstance()->error("队列执行失败原因:订单未支付");
|
Log::getInstance()->error("药品微信退款回调数据处理失败:订单未支付");
|
||||||
return $this->wxPayErrorReturn("退款状态错误");
|
return $this->wxPayErrorReturn("退款状态错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改订单
|
// 修改订单
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
$data['refund_status'] = $refund_status;
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$params['order_product_id'] = $order_product['order_product_id'];
|
||||||
OrderInquiry::edit($params,$data);
|
OrderProduct::edit($params,$data);
|
||||||
|
|
||||||
// 修改退款订单
|
// 修改退款订单
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
$data['product_refund_status'] = $refund_status;
|
||||||
$data['success_time'] = $message['success_time'];
|
$data['success_time'] = $message['success_time'];
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$params['order_product_id'] = $order_product['order_product_id'];
|
||||||
OrderInquiryRefund::edit($params,$data);
|
OrderInquiryRefund::edit($params,$data);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 验证失败
|
// 验证失败
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance()->error("微信支付回调数据验证失败:" . $e->getMessage());
|
Log::getInstance()->error("药品微信退款回调数据处理失败:" . $e->getMessage());
|
||||||
return $this->wxPayErrorReturn($e->getMessage());
|
return $this->wxPayErrorReturn($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::getInstance()->info("微信退款回调处理成功");
|
Log::getInstance()->info("药品微信退款回调数据处理成功");
|
||||||
|
|
||||||
// 发送短信消息
|
// 发送短信消息
|
||||||
|
|
||||||
|
|||||||
94
app/Model/OrderProductRefund.php
Normal file
94
app/Model/OrderProductRefund.php
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use Hyperf\Database\Model\Collection;
|
||||||
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $product_refund_id 主键id
|
||||||
|
* @property int $patient_id 患者id
|
||||||
|
* @property int $order_product_id 订单-药品订单id
|
||||||
|
* @property string $order_product_no 系统订单编号
|
||||||
|
* @property string $product_refund_no 系统退款编号
|
||||||
|
* @property string $refund_id 第三方退款单号
|
||||||
|
* @property int $product_refund_status 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||||
|
* @property string $refund_total 退款金额
|
||||||
|
* @property string $refund_reason 退款原因
|
||||||
|
* @property string $success_time 退款成功时间
|
||||||
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
|
*/
|
||||||
|
class OrderProductRefund extends Model
|
||||||
|
{
|
||||||
|
use Snowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*/
|
||||||
|
protected ?string $table = 'order_product_refund';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*/
|
||||||
|
protected array $fillable = ['product_refund_id', 'patient_id', 'order_product_id', 'order_product_no', 'product_refund_no', 'refund_id', 'product_refund_status', 'refund_total', 'refund_reason', 'success_time', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
protected string $primaryKey = "product_refund_id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取信息-单条
|
||||||
|
* @param array $params
|
||||||
|
* @param array $fields
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||||
|
{
|
||||||
|
return self::where($params)->first($fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据-多
|
||||||
|
* @param array $params
|
||||||
|
* @param array $fields
|
||||||
|
* @return Collection|array
|
||||||
|
*/
|
||||||
|
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||||
|
{
|
||||||
|
return self::where($params)->get($fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取是否存在
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function getExists(array $params): bool
|
||||||
|
{
|
||||||
|
return self::where($params)->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数量
|
||||||
|
* @param array $params
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getCount(array $params): int
|
||||||
|
{
|
||||||
|
return self::where($params)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param array $params
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function edit(array $params = [], array $data = []): int
|
||||||
|
{
|
||||||
|
return self::where($params)->update($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user