|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
namespace app\inter\controller;
|
|
|
|
|
|
+use think\Config;
|
|
|
use think\Controller;
|
|
|
use think\Db;
|
|
|
use think\Session;
|
|
@@ -201,8 +202,8 @@ class Application extends Base
|
|
|
}
|
|
|
$remote_order = DB::table('remote_order')
|
|
|
->where('application_id', $application['id'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
+ ->where('status', 'neq', Config::get('ORDER_STATUS')['CANCEL'])
|
|
|
+ ->where('status', 'neq', Config::get('ORDER_STATUS')['REDUCE'])
|
|
|
->field('id, status, exam_class, super_hospital_id, super_doctor_id')
|
|
|
->find();
|
|
|
if($remote_order) {
|
|
@@ -276,7 +277,7 @@ class Application extends Base
|
|
|
if(!$remote_order) {
|
|
|
return json_encode(['status'=>'fail','code'=>'2101','msg'=> '没有找到该订单']);
|
|
|
}
|
|
|
- if(!($remote_order['status'] === self::ORDER_STATUS['CREATE'] || $remote_order['status'] === self::ORDER_STATUS['PAYCOMPLTET'])) {
|
|
|
+ if(!($remote_order['status'] === Config::get('ORDER_STATUS')['CREATE'] || $remote_order['status'] === Config::get('ORDER_STATUS')['PAYCOMPLTET'])) {
|
|
|
return json_encode(['status'=>'fail','code'=>'2102','msg'=> '订单状态不可取消']);
|
|
|
}
|
|
|
$application = DB::table('remote_application')->where('id', $remote_order['application_id'])->field('report_status, exam_id')->find();
|
|
@@ -289,10 +290,10 @@ class Application extends Base
|
|
|
// 微信消息推送
|
|
|
// $wechatService->pushWechatCancel($application['exam_id']);
|
|
|
$wechatService->pushWechatCancel($order_id);
|
|
|
- if($remote_order['pay_type'] === self::PAY_TYPE['HOSPITAL']) {
|
|
|
+ if($remote_order['pay_type'] === Config::get('PAY_TYPE')['HOSPITAL']) {
|
|
|
return $this->cancelHospitalOrder($order_id, $remote_order['hospital_id'], $remote_order['order_money']);
|
|
|
}
|
|
|
- if($remote_order['pay_type'] === self::PAY_TYPE['PATIENT']) {
|
|
|
+ if($remote_order['pay_type'] === Config::get('PAY_TYPE')['PATIENT']) {
|
|
|
return $this->cancelPatientsOrder($order_id, $remote_order['application_id']);
|
|
|
}
|
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid]);
|
|
@@ -515,11 +516,11 @@ class Application extends Base
|
|
|
return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
|
|
|
}
|
|
|
$res = false;
|
|
|
- if($contact['pay_type'] === self::PAY_TYPE['HOSPITAL']) { //医院挂账
|
|
|
+ if($contact['pay_type'] === Config::get('PAY_TYPE')['HOSPITAL']) { //医院挂账
|
|
|
// $hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money
|
|
|
$res = $this->createHospitalOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money'], $is_urgent, $wechatService);
|
|
|
}
|
|
|
- if($contact['pay_type'] === self::PAY_TYPE['PATIENT']) { // 患者支付
|
|
|
+ if($contact['pay_type'] === Config::get('PAY_TYPE')['PATIENT']) { // 患者支付
|
|
|
// var_dump(2);
|
|
|
// var_dump($wechatService);
|
|
|
// $push_res = WechatService::pushWechatOrder($param['id']);
|
|
@@ -542,10 +543,10 @@ class Application extends Base
|
|
|
'application_id' => $application['id'],
|
|
|
'super_doctor_id' => $remote_doctor_id,
|
|
|
'is_urgent' => $is_urgent,
|
|
|
- 'status' => self::ORDER_STATUS['PAYCOMPLTET'],
|
|
|
+ 'status' => Config::get('ORDER_STATUS')['PAYCOMPLTET'],
|
|
|
'order_money' => 0,
|
|
|
- 'pay_type' => self::PAY_TYPE['HOSPITAL'],
|
|
|
- 'pay_way' => self::PAY_WAY['HOSPITAL'],
|
|
|
+ 'pay_type' => Config::get('PAY_TYPE')['HOSPITAL'],
|
|
|
+ 'pay_way' => Config::get('PAY_WAY')['HOSPITAL'],
|
|
|
'timestamp' => time()
|
|
|
]);
|
|
|
DB::table('remote_application')->where('exam_id',$param['id'])->update(['report_status'=>4]);
|
|
@@ -608,15 +609,15 @@ class Application extends Base
|
|
|
|
|
|
private function createHospitalOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0, $wechatService) {
|
|
|
DB::startTrans();
|
|
|
- $pay_type = self::PAY_TYPE['HOSPITAL'];
|
|
|
- $pay_way = self::PAY_TYPE['HOSPITAL'];
|
|
|
- $water_type = self::WATER_TYPE['REDUCE'];
|
|
|
- $water_why = self::WATER_WHY['REMOTEPAY'];
|
|
|
+ $pay_type = Config::get('PAY_TYPE')['HOSPITAL'];
|
|
|
+ $pay_way = Config::get('PAY_TYPE')['HOSPITAL'];
|
|
|
+ $water_type = Config::get('WATER_TYPE')['REDUCE'];
|
|
|
+ $water_why = Config::get('WATER_WHY')['REMOTEPAY'];
|
|
|
try{
|
|
|
$remote_order = DB::table('remote_order')
|
|
|
->where('application_id', $application_id)
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
+ ->where('status', 'neq', Config::get('ORDER_STATUS')['CANCEL'])
|
|
|
+ ->where('status', 'neq', Config::get('ORDER_STATUS')['REDUCE'])
|
|
|
->field('id')
|
|
|
->find();
|
|
|
DB::table('remote_application')->where('id',$application_id)->update(['report_status'=>4]);
|
|
@@ -676,14 +677,14 @@ class Application extends Base
|
|
|
return json_encode(['status'=>'fail','code'=>'2018','msg' => '远程诊断发起失败']);
|
|
|
}
|
|
|
private function createPatientsOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0, $wechatService) {
|
|
|
- $pay_type = self::PAY_TYPE['PATIENT'];
|
|
|
- $pay_way = self::PAY_WAY['WECHAT'];
|
|
|
+ $pay_type = Config::get('PAY_TYPE')['PATIENT'];
|
|
|
+ $pay_way = Config::get('PAY_WAY')['WECHAT'];
|
|
|
DB::startTrans();
|
|
|
try{
|
|
|
$remote_order = DB::table('remote_order')
|
|
|
->where('application_id', $application_id)
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['CANCEL'])
|
|
|
- ->where('status', 'neq', self::ORDER_STATUS['REDUCE'])
|
|
|
+ ->where('status', 'neq', Config::get('ORDER_STATUS')['CANCEL'])
|
|
|
+ ->where('status', 'neq', Config::get('ORDER_STATUS')['REDUCE'])
|
|
|
->field('id')
|
|
|
->find();
|
|
|
DB::table('remote_application')->where('id',$application_id)->update(['report_status'=>4]);
|
|
@@ -707,7 +708,7 @@ class Application extends Base
|
|
|
'pay_type' => $pay_type,
|
|
|
'pay_way' => $pay_way,
|
|
|
'timestamp' => time(),
|
|
|
- 'status' => self::ORDER_STATUS['CREATE']
|
|
|
+ 'status' => Config::get('ORDER_STATUS')['CREATE']
|
|
|
]);
|
|
|
DB::commit();
|
|
|
$wechatService->pushWechatOrder($order_id);
|
|
@@ -721,10 +722,10 @@ class Application extends Base
|
|
|
|
|
|
private function cancelHospitalOrder($order_id, $hospital_id, $order_money) {
|
|
|
DB::startTrans();
|
|
|
- $water_type = self::WATER_TYPE['ADD'];
|
|
|
- $water_why = self::WATER_WHY['REFUNDINCOME'];
|
|
|
+ $water_type = Config::get('WATER_TYPE')['ADD'];
|
|
|
+ $water_why = Config::get('WATER_WHY')['REFUNDINCOME'];
|
|
|
try{
|
|
|
- DB::table('remote_order')->where('id', $order_id)->update(["status" => self::ORDER_STATUS["REDUCE"]]);
|
|
|
+ DB::table('remote_order')->where('id', $order_id)->update(["status" => Config::get('ORDER_STATUS')["REDUCE"]]);
|
|
|
$hospital = DB::table('institution')
|
|
|
->where('id', $hospital_id)
|
|
|
->field('current_money')
|
|
@@ -752,7 +753,7 @@ class Application extends Base
|
|
|
}
|
|
|
private function cancelPatientsOrder($order_id) {
|
|
|
try{
|
|
|
- DB::table('remote_order')->where('id', $order_id)->update(["status" => self::ORDER_STATUS["CANCEL"]]);
|
|
|
+ DB::table('remote_order')->where('id', $order_id)->update(["status" => Config::get('ORDER_STATUS')["CANCEL"]]);
|
|
|
// todo 消息推送
|
|
|
return json_encode(['status'=>'ok','code'=>'0000']);
|
|
|
} catch (\Exception $e) {
|
|
@@ -761,43 +762,6 @@ class Application extends Base
|
|
|
return json_encode(['status'=>'fail','code'=>'2109','msg' => '订单取消失败']);
|
|
|
}
|
|
|
|
|
|
- /**订单状态 创建 支付完成 订单完成 取消 退款 */
|
|
|
- public const ORDER_STATUS = [
|
|
|
- 'CREATE' => 1,
|
|
|
- 'PAYCOMPLTET' => 2,
|
|
|
- 'CONFIRM' => 3,
|
|
|
- 'CANCEL' => 4,
|
|
|
- 'REDUCE' => 5
|
|
|
- ];
|
|
|
-
|
|
|
- /**流水类型 加 减 */
|
|
|
- public const WATER_TYPE = [
|
|
|
- 'ADD' => 1,
|
|
|
- 'REDUCE' => 2
|
|
|
- ];
|
|
|
-
|
|
|
- /**流水原因 远程诊断医院扣款 远程诊断医院收入 远程诊断退款 远程诊断退款收入 */
|
|
|
- public const WATER_WHY = [
|
|
|
- 'REMOTEPAY' => 21,
|
|
|
- 'REMOTEINCOME' => 11,
|
|
|
- 'REMOTEREFUND' => 22,
|
|
|
- 'REFUNDINCOME' => 12
|
|
|
- ];
|
|
|
- // why 患者支付/远程诊断收入/远程诊断付款/远程诊断退款/提现
|
|
|
- /**支付方式 微信 支付宝 银联 医院扣款*/
|
|
|
- public const PAY_WAY = [
|
|
|
- "HOSPITAL" => 1,
|
|
|
- "WECHAT" => 11,
|
|
|
- "ALIPAY" => 12,
|
|
|
- "BANK" => 13
|
|
|
- ];
|
|
|
-
|
|
|
- /**支付类型 微信 医院 */
|
|
|
- public const PAY_TYPE = [
|
|
|
- "PATIENT" => 0,
|
|
|
- "HOSPITAL" => 1
|
|
|
- ];
|
|
|
-
|
|
|
/**
|
|
|
* 上传附件
|
|
|
*
|