新增功能

This commit is contained in:
Your Name
2026-03-14 11:16:04 +08:00
parent eb283f008b
commit 4ddee40675
264 changed files with 5039 additions and 2813 deletions
+1
View File
@@ -98,6 +98,7 @@ class AdminTokenCache extends BaseCache
'terminal' => $adminSession->terminal,
'expire_time' => $adminSession->expire_time,
'login_ip' => request()->ip(),
'work_wechat_userid' => $admin->work_wechat_userid ?? '',
];
$this->set($this->prefix . $token, $adminInfo, new \DateTime(Date('Y-m-d H:i:s', $adminSession->expire_time)));
return $this->getAdminInfo($token);
+19 -1
View File
@@ -84,5 +84,23 @@ class PayNotifyLogic extends BaseLogic
$order->save();
}
/**
* @notes 订单支付回调
* @param $orderSn
* @param array $extra
*/
public static function order($orderSn, array $extra = [])
{
$order = \app\common\model\Order::where('order_no', $orderSn)->findOrEmpty();
if ($order->isEmpty()) {
throw new \Exception('订单不存在: ' . $orderSn);
}
if ($order->status == 2) {
return;
}
$order->status = 2;
$order->pay_time = date('Y-m-d H:i:s');
$order->transaction_id = $extra['transaction_id'] ?? '';
$order->save();
}
}
+37 -1
View File
@@ -45,8 +45,14 @@ class PaymentLogic extends BaseLogic
{
try {
if ($params['from'] == 'recharge') {
// 充值
$order = RechargeOrder::findOrEmpty($params['order_id'])->toArray();
} elseif ($params['from'] == 'order') {
$orderModel = \app\common\model\Order::findOrEmpty($params['order_id']);
if (!$orderModel->isEmpty()) {
$order = $orderModel->toArray();
$order['order_amount'] = $order['amount'];
$order['sn'] = $order['order_no'];
}
}
if (empty($order)) {
@@ -117,6 +123,21 @@ class PaymentLogic extends BaseLogic
'pay_time' => $payTime,
];
break;
case 'order':
$order = \app\common\model\Order::where(['id' => $params['order_id']])
->findOrEmpty();
$statusMap = [1 => 0, 2 => 1, 3 => 0, 4 => 0];
$order['pay_status'] = $statusMap[$order['status']] ?? 0;
$order['pay_way'] = $order['pay_way'] ?? 0;
$orderInfo = [
'order_id' => $order['id'],
'order_sn' => $order['order_no'],
'order_amount' => $order['amount'],
'pay_way' => PayEnum::getPayDesc($order['pay_way']),
'pay_status' => $order['status'] == 2 ? '已支付' : '未支付',
'pay_time' => $order['pay_time'] ?? '',
];
break;
}
if (empty($order)) {
@@ -152,6 +173,18 @@ class PaymentLogic extends BaseLogic
throw new \Exception('充值订单不存在');
}
break;
case 'order':
$order = \app\common\model\Order::findOrEmpty($params['order_id']);
if ($order->isEmpty()) {
throw new \Exception('订单不存在');
}
if ($order['status'] == 2) {
throw new \Exception('订单已支付');
}
$order['order_amount'] = $order['amount'];
$order['sn'] = $order['order_no'];
$order['pay_status'] = PayEnum::UNPAID;
return $order;
}
if ($order['pay_status'] == PayEnum::ISPAID) {
@@ -189,6 +222,9 @@ class PaymentLogic extends BaseLogic
case 'recharge':
RechargeOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]);
break;
case 'order':
\app\common\model\Order::update(['pay_way' => $payWay], ['id' => $order['id']]);
break;
}
if ($order['order_amount'] == 0) {
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace app\common\model;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
class Fan extends BaseModel
{
use SoftDelete;
protected $name = 'fan';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
protected $dateFormat = false;
public function getGenderDescAttr($value, $data)
{
$gender = [0 => '未知', 1 => '男', 2 => '女'];
return $gender[$data['gender']] ?? '未知';
}
public function getStatusDescAttr($value, $data)
{
$status = [0 => '禁用', 1 => '启用'];
return $status[$data['status']] ?? '未知';
}
public function visitRecords()
{
return $this->hasMany(FanVisitRecord::class, 'fan_id', 'id');
}
}
@@ -0,0 +1,29 @@
<?php
namespace app\common\model;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
class FanVisitRecord extends BaseModel
{
use SoftDelete;
protected $name = 'fan_visit_record';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = 'delete_time';
protected $dateFormat = false;
public function getVisitTypeDescAttr($value, $data)
{
$types = [1 => '电话', 2 => '微信', 3 => '短信', 4 => '上门', 5 => '其他'];
return $types[$data['visit_type']] ?? '未知';
}
public function fan()
{
return $this->belongsTo(Fan::class, 'fan_id', 'id');
}
}
@@ -0,0 +1,14 @@
<?php
namespace app\common\model;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
class WechatChatRecord extends BaseModel
{
use SoftDelete;
protected $name = 'wechat_chat_record';
protected $deleteTime = 'delete_time';
}
+5 -1
View File
@@ -15,7 +15,7 @@
namespace app\common\model\tcm;
use app\common\model\BaseModel;
use app\common\model\DiagnosisViewRecord;
/**
* 中医辨房病因诊单模型
* Class Diagnosis
@@ -92,4 +92,8 @@ class Diagnosis extends BaseModel
}
return null;
}
public function DiagnosisViewRecord()
{
return $this->hasMany(DiagnosisViewRecord::class, 'diagnosis_id', 'id');
}
}
@@ -374,14 +374,22 @@ class WeChatPayService extends BasePayService
if ($message['trade_state'] === 'SUCCESS') {
$extra['transaction_id'] = $message['transaction_id'];
$attach = $message['attach'];
$message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18);
switch ($attach) {
case 'recharge':
$order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty();
$outTradeNo = mb_substr($message['out_trade_no'], 0, 18);
$order = RechargeOrder::where(['sn' => $outTradeNo])->findOrEmpty();
if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) {
return true;
}
PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra);
PayNotifyLogic::handle('recharge', $outTradeNo, $extra);
break;
case 'order':
$outTradeNo = mb_substr($message['out_trade_no'], 0, 23);
$orderModel = \app\common\model\Order::where(['order_no' => $outTradeNo])->findOrEmpty();
if($orderModel->isEmpty() || $orderModel->status == 2) {
return true;
}
PayNotifyLogic::handle('order', $outTradeNo, $extra);
break;
}
}