获取我的账户月账单明细数据数据修改
This commit is contained in:
parent
4fdf7e2cc2
commit
5600baf259
@ -7,16 +7,23 @@ use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
|||||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||||
use App\Amqp\Producer\SendSmsMessageProducer;
|
use App\Amqp\Producer\SendSmsMessageProducer;
|
||||||
|
use App\Constants\DoctorTitleCode;
|
||||||
use App\Constants\HttpEnumCode;
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Exception\BusinessException;
|
use App\Exception\BusinessException;
|
||||||
use App\Factory\CacheFactory;
|
use App\Factory\CacheFactory;
|
||||||
use App\Factory\ProdRedisFactory;
|
use App\Factory\ProdRedisFactory;
|
||||||
|
use App\Model\DoctorConfigFollowPackage;
|
||||||
|
use App\Model\DoctorConfigFollowPackageItem;
|
||||||
|
use App\Model\DoctorConfigHealthPackage;
|
||||||
use App\Model\DoctorInquiryTime;
|
use App\Model\DoctorInquiryTime;
|
||||||
use App\Model\HospitalDepartmentCustom;
|
use App\Model\HospitalDepartmentCustom;
|
||||||
|
use App\Model\Order;
|
||||||
use App\Model\OrderInquiryCase;
|
use App\Model\OrderInquiryCase;
|
||||||
|
use App\Model\OrderInquiryRefund;
|
||||||
use App\Model\OrderPrescriptionProduct;
|
use App\Model\OrderPrescriptionProduct;
|
||||||
use App\Model\OrderProduct;
|
use App\Model\OrderProduct;
|
||||||
use App\Model\OrderProductItem;
|
use App\Model\OrderProductItem;
|
||||||
|
use App\Model\OrderServicePackageRefund;
|
||||||
use App\Model\PatientFamily;
|
use App\Model\PatientFamily;
|
||||||
use App\Model\ReportRegulatory;
|
use App\Model\ReportRegulatory;
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
@ -447,62 +454,112 @@ class TestController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_17(){
|
public function test_17(){
|
||||||
$expertise_id = $this->request->input('expertise_id');
|
$params = array();
|
||||||
$province_id = $this->request->input('province_id');
|
$params['doctor_id'] = "516900370252341248";
|
||||||
$city_id = $this->request->input('city_id');
|
|
||||||
$sort_order = $this->request->input('sort_order',1);
|
|
||||||
$keyword = $this->request->input('keyword',"");
|
|
||||||
$is_search_welfare_reception = $this->request->input('is_search_welfare_reception',0); // 是否参加公益图文问诊(0:否 1:是)
|
|
||||||
$is_first_online = $this->request->input('is_first_online',0); // 是否优先在线(1:是)
|
|
||||||
$page = $this->request->input('page',1);
|
|
||||||
$per_page = $this->request->input('per_page',10);
|
|
||||||
|
|
||||||
// 组合条件
|
// 获取当月开始时间
|
||||||
$hospital_params = array();// 医院搜索
|
$start_date = date('Y-m-01 00:00:00', strtotime("2024-04-19"));
|
||||||
$doctor_params = array();// 医生搜索
|
|
||||||
$doctor_expertise_params = array();// 医生专长搜索
|
|
||||||
|
|
||||||
// 省市区
|
// 获取当月结束时间
|
||||||
if (!empty($province_id)) {
|
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
||||||
if (empty($city_id)) {
|
$end_date = date("Y-m-d 23:59:59", strtotime("+1 month", strtotime($start_date)) - 1);
|
||||||
// 省份存在时需和城市在一块
|
|
||||||
return fail(HttpEnumCode::CLIENT_HTTP_ERROR);
|
$date_params = [$start_date, $end_date];
|
||||||
}
|
|
||||||
$hospital_params[] = ['province_id', '=', $province_id];
|
$results = Order::getDoctorCreatedDateOrderInquiryPage($params,$date_params,1,["*"]);
|
||||||
$hospital_params[] = ['city_id', '=', $city_id];
|
if (!empty($results['data'])) {
|
||||||
|
foreach ($results['data'] as &$result) {
|
||||||
|
// 入账金额
|
||||||
|
$result['estimate_income'] = bcmul((string)$result['amount_total'],"0.75",2);
|
||||||
|
|
||||||
|
// 入账状态-问诊订单
|
||||||
|
if (!empty($result['OrderInquiry'])){
|
||||||
|
if ($result['OrderInquiry']['inquiry_status'] == 4 || $result['OrderInquiry']['inquiry_status'] == 5){
|
||||||
|
$result['entry_status'] = 1;// 入账中
|
||||||
|
}elseif ($result['OrderInquiry']['inquiry_status'] == 6){
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}elseif ($result['OrderInquiry']['inquiry_status'] == 7){
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
// 获取退款数据
|
||||||
|
$params = array();
|
||||||
|
$params['inquiry_no'] = $result['OrderInquiry']['inquiry_no'];
|
||||||
|
$order_inquiry_refunds = OrderInquiryRefund::getList($params);
|
||||||
|
if (!empty($order_inquiry_refunds)){
|
||||||
|
$refund_total = 0;
|
||||||
|
foreach ($order_inquiry_refunds as $order_inquiry_refund){
|
||||||
|
$refund_total = $refund_total + $order_inquiry_refund['refund_total'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 医生专长
|
// 订单退款金额
|
||||||
if (!empty($expertise_id)) {
|
$result['refund_total'] = $refund_total;
|
||||||
$doctor_expertise_params['expertise_id'] = $expertise_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 固定医生查询条件
|
if (($result['OrderInquiry']['payment_amount_total'] - $refund_total) > 0){
|
||||||
$doctor_params['status'] = 1; // 状态(0:禁用 1:正常 2:删除)
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}else{
|
||||||
$doctor_params["iden_auth_status"] = 1;// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
$result['entry_status'] = 3;// 入账失败
|
||||||
$doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是)
|
}
|
||||||
|
}
|
||||||
$fields = [
|
|
||||||
"doctor_id",
|
if (!empty($result['OrderInquiry']['cancel_reason'])){
|
||||||
"user_id",
|
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||||
"user_name",
|
}
|
||||||
"multi_point_status",
|
}else{
|
||||||
"is_bind_bank",
|
$result['entry_status'] = 0;// 未知
|
||||||
"is_recommend",
|
}
|
||||||
"avatar",
|
|
||||||
"doctor_title",
|
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||||
"department_custom_id",
|
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||||
"department_custom_name",
|
$result['patient_sex'] = $result['OrderInquiry']['patient_sex'];
|
||||||
"hospital_id",
|
$result['patient_age'] = $result['OrderInquiry']['patient_age'];
|
||||||
"served_patients_num",
|
$result['start_time'] = $result['OrderInquiry']['reception_time'];
|
||||||
"praise_rate",
|
$result['finish_time'] = $result['OrderInquiry']['finish_time'];
|
||||||
"avg_response_time",
|
$result['inquiry_type'] = $result['OrderInquiry']['inquiry_type'];
|
||||||
"number_of_fans",
|
$result['inquiry_mode'] = $result['OrderInquiry']['inquiry_mode'];
|
||||||
"be_good_at",
|
}
|
||||||
];
|
|
||||||
|
// 入账状态-服务包订单
|
||||||
$user_doctors = UserDoctor::getInquiryDoctorPageTest($keyword,$hospital_params, $doctor_params,$doctor_expertise_params,$is_search_welfare_reception,$is_first_online, $sort_order, ['*'],$page,$per_page);
|
if (!empty($result['OrderServicePackage'])){
|
||||||
return success($user_doctors);
|
if ($result['OrderServicePackage']['order_service_status'] == 3){
|
||||||
|
$result['entry_status'] = 1;// 入账中
|
||||||
|
}elseif ($result['OrderServicePackage']['order_service_status'] == 4){
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}elseif ($result['OrderServicePackage']['order_service_status'] == 5){
|
||||||
|
// 获取退款数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||||
|
$order_service_package_refunds = OrderServicePackageRefund::getList($params);
|
||||||
|
if (!empty($order_service_package_refunds)){
|
||||||
|
$refund_total = 0;
|
||||||
|
foreach ($order_service_package_refunds as $order_service_package_refund){
|
||||||
|
$refund_total = $refund_total + $order_service_package_refund['refund_total'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单退款金额
|
||||||
|
$result['refund_total'] = $refund_total;
|
||||||
|
|
||||||
|
if (($result['OrderServicePackage']['payment_amount_total'] - $refund_total) > 0){
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}else{
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$result['entry_status'] = 0;// 未知
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
||||||
|
$result['patient_name_mask'] = $result['OrderServicePackage']['patient_name_mask'];
|
||||||
|
$result['patient_sex'] = $result['OrderServicePackage']['patient_sex'];
|
||||||
|
$result['patient_age'] = $result['OrderServicePackage']['patient_age'];
|
||||||
|
$result['start_time'] = $result['OrderServicePackage']['start_time'];
|
||||||
|
$result['finish_time'] = $result['OrderServicePackage']['finish_time'];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($result['OrderInquiry']);
|
||||||
|
unset($result['OrderServicePackage']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success($results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,6 +8,8 @@ namespace App\Model;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Hyperf\Database\Model\Collection;
|
use Hyperf\Database\Model\Collection;
|
||||||
|
use Hyperf\Database\Model\Relations\HasOne;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Snowflake\Concern\Snowflake;
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,8 +32,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property string $cancel_time 订单取消时间
|
* @property string $cancel_time 订单取消时间
|
||||||
* @property string $cancel_remarks 取消订单备注
|
* @property string $cancel_remarks 取消订单备注
|
||||||
* @property string $order_remarks 订单备注
|
* @property string $order_remarks 订单备注
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property Carbon $updated_at 修改时间
|
||||||
*/
|
*/
|
||||||
class Order extends Model
|
class Order extends Model
|
||||||
{
|
{
|
||||||
@ -49,6 +51,22 @@ class Order extends Model
|
|||||||
|
|
||||||
protected string $primaryKey = "order_id";
|
protected string $primaryKey = "order_id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联问诊订单表
|
||||||
|
*/
|
||||||
|
public function OrderInquiry(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(OrderInquiry::class, 'order_id', 'order_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联服务包订单表
|
||||||
|
*/
|
||||||
|
public function OrderServicePackage(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(OrderServicePackage::class, 'order_id', 'order_id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息-单条
|
* 获取信息-单条
|
||||||
* @param array $params
|
* @param array $params
|
||||||
@ -92,4 +110,50 @@ class Order extends Model
|
|||||||
return self::where($params)->update($data);
|
return self::where($params)->update($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取医生某一时间段收益明细分页数据
|
||||||
|
* @param array $params
|
||||||
|
* @param array $date_params 时间区间
|
||||||
|
* @param string|int $is_platform_deep_cooperation
|
||||||
|
* @param array $fields
|
||||||
|
* @param int|null $page
|
||||||
|
* @param int|null $per_page
|
||||||
|
* @return int|mixed|string
|
||||||
|
*/
|
||||||
|
public static function getDoctorCreatedDateOrderInquiryPage(array $params, array $date_params,string|int $is_platform_deep_cooperation,array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||||
|
{
|
||||||
|
$query = self::with(['OrderInquiry', 'OrderServicePackage'])->where($params);
|
||||||
|
|
||||||
|
// 问诊订单
|
||||||
|
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
||||||
|
$query->whereExists(function ($subQuery) use ($date_params,$is_platform_deep_cooperation){
|
||||||
|
$subQuery->from('order_inquiry');
|
||||||
|
if ($is_platform_deep_cooperation == 1){
|
||||||
|
$subQuery->whereNotIn('inquiry_type', [2,4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$subQuery->whereNotIn('inquiry_mode', [7,8,9])
|
||||||
|
->whereIn('inquiry_status', [4,5,6,7])
|
||||||
|
->whereBetween('reception_time', $date_params)
|
||||||
|
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
||||||
|
})
|
||||||
|
->orWhereExists(function ($subQuery) use ($date_params) {
|
||||||
|
$subQuery->from('order_service_package')
|
||||||
|
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
||||||
|
->whereIn('order_service_status', [4,5,6,7])
|
||||||
|
->whereBetween('start_time', $date_params);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$result = $query->paginate($per_page, $fields, "page", $page);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['current_page'] = $result->currentPage();// 当前页码
|
||||||
|
$data['total'] = $result->total();//数据总数
|
||||||
|
$data['data'] = $result->items();//数据
|
||||||
|
$data['per_page'] = $result->perPage();//每页个数
|
||||||
|
$data['last_page'] = $result->lastPage();//最后一页
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Model;
|
namespace App\Model;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Hyperf\Database\Model\Collection;
|
use Hyperf\Database\Model\Collection;
|
||||||
use Hyperf\Database\Model\Relations\HasOne;
|
use Hyperf\Database\Model\Relations\HasOne;
|
||||||
use Hyperf\Database\Query\Builder;
|
use Hyperf\Database\Query\Builder;
|
||||||
@ -47,8 +48,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
||||||
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
||||||
* @property int $patient_age 患者年龄-就诊人
|
* @property int $patient_age 患者年龄-就诊人
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property Carbon $updated_at 修改时间
|
||||||
* @property-read UserDoctor|null $UserDoctor
|
* @property-read UserDoctor|null $UserDoctor
|
||||||
* @property-read OrderInquiryCase|null $OrderInquiryCase
|
* @property-read OrderInquiryCase|null $OrderInquiryCase
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -41,8 +41,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
||||||
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
||||||
* @property int $patient_age 患者年龄-就诊人
|
* @property int $patient_age 患者年龄-就诊人
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property Carbon $updated_at 修改时间
|
||||||
* @property-read OrderServicePackageCase|null $OrderServicePackageCase
|
* @property-read OrderServicePackageCase|null $OrderServicePackageCase
|
||||||
*/
|
*/
|
||||||
class OrderServicePackage extends Model
|
class OrderServicePackage extends Model
|
||||||
|
|||||||
@ -10,7 +10,10 @@ use App\Model\DoctorBankCard;
|
|||||||
use App\Model\DoctorWithdrawal;
|
use App\Model\DoctorWithdrawal;
|
||||||
use App\Model\DoctorWithdrawalBank;
|
use App\Model\DoctorWithdrawalBank;
|
||||||
use App\Model\DoctorWithdrawalOrder;
|
use App\Model\DoctorWithdrawalOrder;
|
||||||
|
use App\Model\Order;
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
|
use App\Model\OrderInquiryRefund;
|
||||||
|
use App\Model\OrderServicePackageRefund;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserDoctorInfo;
|
use App\Model\UserDoctorInfo;
|
||||||
use Hyperf\DbConnection\Db;
|
use Hyperf\DbConnection\Db;
|
||||||
@ -105,65 +108,113 @@ class DoctorAccountService extends BaseService
|
|||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||||
|
|
||||||
// 获取当月开始时间
|
// 获取当月开始时间
|
||||||
$start_date = date('Y-m-01 00:00:00', strtotime($date));
|
$start_date = date('Y-m-01 00:00:00',$date);
|
||||||
|
|
||||||
// 获取当月结束时间
|
// 获取当月结束时间
|
||||||
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
||||||
$end_date = date("Y-m-d 23:59:59", strtotime("+1 month", strtotime($start_date)) - 1);
|
$end_date = date("Y-m-d 23:59:59", strtotime("+1 month", strtotime($start_date)) - 1);
|
||||||
|
|
||||||
$reception_time = [$start_date, $end_date];
|
$date_params = [$start_date, $end_date];
|
||||||
|
|
||||||
// 获取医生当日接诊订单金额
|
$results = Order::getDoctorCreatedDateOrderInquiryPage($params,$date_params,$user_doctor['is_platform_deep_cooperation'],['*'],$page,$per_page);
|
||||||
$fields = [
|
if (!empty($results['data'])) {
|
||||||
'order_inquiry_id',
|
foreach ($results['data'] as &$result) {
|
||||||
'inquiry_type',
|
// 入账金额
|
||||||
'inquiry_mode',
|
$result['estimate_income'] = bcmul((string)$result['amount_total'],"0.75",2);
|
||||||
'inquiry_status',
|
|
||||||
'inquiry_refund_status',
|
|
||||||
'inquiry_no',
|
|
||||||
'amount_total',
|
|
||||||
'payment_amount_total',
|
|
||||||
'reception_time',
|
|
||||||
'finish_time',
|
|
||||||
'patient_name',
|
|
||||||
'patient_sex',
|
|
||||||
'patient_age',
|
|
||||||
'cancel_reason',
|
|
||||||
'cancel_remarks',
|
|
||||||
'created_at',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
// 入账状态-问诊订单
|
||||||
|
if (!empty($result['OrderInquiry'])){
|
||||||
|
if ($result['OrderInquiry']['inquiry_status'] == 4 || $result['OrderInquiry']['inquiry_status'] == 5){
|
||||||
|
$result['entry_status'] = 1;// 入账中
|
||||||
|
}elseif ($result['OrderInquiry']['inquiry_status'] == 6){
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}elseif ($result['OrderInquiry']['inquiry_status'] == 7){
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
// 获取退款数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['inquiry_no'] = $result['OrderInquiry']['inquiry_no'];
|
||||||
$inquiry_status_params = [4,5,6,7]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
$order_inquiry_refunds = OrderInquiryRefund::getList($params);
|
||||||
|
if (!empty($order_inquiry_refunds)){
|
||||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
$refund_total = 0;
|
||||||
$order_inquiry = OrderInquiry:: getDoctorCreatedDateOrderInquiryPage($params, $reception_time, $inquiry_status_params,[],$fields,$page,$per_page);
|
foreach ($order_inquiry_refunds as $order_inquiry_refund){
|
||||||
}else{
|
$refund_total = $refund_total + $order_inquiry_refund['refund_total'];
|
||||||
$order_inquiry = OrderInquiry:: getDoctorCreatedDateOrderInquiryPage($params, $reception_time, $inquiry_status_params,[2,4],$fields,$page,$per_page);
|
|
||||||
}
|
}
|
||||||
if (!empty($order_inquiry['data'])) {
|
|
||||||
foreach ($order_inquiry['data'] as &$item) {
|
|
||||||
$item['estimate_income'] = bcmul((string)$item['amount_total'],"0.75",2);
|
|
||||||
|
|
||||||
// 入账状态
|
// 订单退款金额
|
||||||
if ($item['inquiry_status'] == 4 || $item['inquiry_status'] == 5){
|
$result['refund_total'] = $refund_total;
|
||||||
$item['entry_status'] = 1;// 入账中
|
|
||||||
}elseif ($item['inquiry_status'] == 6){
|
if (($result['OrderInquiry']['payment_amount_total'] - $refund_total) > 0){
|
||||||
$item['entry_status'] = 2;// 入账成功
|
$result['entry_status'] = 2;// 入账成功
|
||||||
}elseif ($item['inquiry_status'] == 7){
|
}else{
|
||||||
$item['entry_status'] = 3;// 入账失败
|
$result['entry_status'] = 3;// 入账失败
|
||||||
if (!empty($item['cancel_reason'])){
|
}
|
||||||
$item['cancel_reason'] = inquiryCancelReasonToPushString($item['cancel_reason']);
|
}
|
||||||
|
|
||||||
|
if (!empty($result['OrderInquiry']['cancel_reason'])){
|
||||||
|
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$item['entry_status'] = 0;// 未知
|
$result['entry_status'] = 0;// 未知
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||||
|
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||||
|
$result['patient_sex'] = $result['OrderInquiry']['patient_sex'];
|
||||||
|
$result['patient_age'] = $result['OrderInquiry']['patient_age'];
|
||||||
|
$result['start_time'] = $result['OrderInquiry']['reception_time'];
|
||||||
|
$result['finish_time'] = $result['OrderInquiry']['finish_time'];
|
||||||
|
$result['inquiry_type'] = $result['OrderInquiry']['inquiry_type'];
|
||||||
|
$result['inquiry_mode'] = $result['OrderInquiry']['inquiry_mode'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 入账状态-服务包订单
|
||||||
|
if (!empty($result['OrderServicePackage'])){
|
||||||
|
if ($result['OrderServicePackage']['order_service_status'] == 3){
|
||||||
|
$result['entry_status'] = 1;// 入账中
|
||||||
|
}elseif ($result['OrderServicePackage']['order_service_status'] == 4){
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}elseif ($result['OrderServicePackage']['order_service_status'] == 5){
|
||||||
|
// 获取退款数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||||
|
$order_service_package_refunds = OrderServicePackageRefund::getList($params);
|
||||||
|
if (!empty($order_service_package_refunds)){
|
||||||
|
$refund_total = 0;
|
||||||
|
foreach ($order_service_package_refunds as $order_service_package_refund){
|
||||||
|
$refund_total = $refund_total + $order_service_package_refund['refund_total'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单退款金额
|
||||||
|
$result['refund_total'] = $refund_total;
|
||||||
|
|
||||||
|
if (($result['OrderServicePackage']['payment_amount_total'] - $refund_total) > 0){
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
}else{
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$result['entry_status'] = 0;// 未知
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
||||||
|
$result['patient_name_mask'] = $result['OrderServicePackage']['patient_name_mask'];
|
||||||
|
$result['patient_sex'] = $result['OrderServicePackage']['patient_sex'];
|
||||||
|
$result['patient_age'] = $result['OrderServicePackage']['patient_age'];
|
||||||
|
$result['start_time'] = $result['OrderServicePackage']['start_time'];
|
||||||
|
$result['finish_time'] = $result['OrderServicePackage']['finish_time'];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($result['OrderInquiry']);
|
||||||
|
unset($result['OrderServicePackage']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success($order_inquiry);
|
return success($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user