| xqd
@@ -44,8 +44,13 @@ class OrderController extends AuthController
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
|
|
- if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
|
|
|
- return out(null, 10001, '密码错误');
|
|
|
+ if (!empty($req['pay_password'])) {
|
|
|
+ if (empty($user['pay_password'])) {
|
|
|
+ return out(null, 60010, '未设置支付密码');
|
|
|
+ }
|
|
|
+ if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
|
|
|
+ return out(null, 10001, '密码错误');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$discount_amount = 0;
|
| xqd
@@ -89,7 +94,7 @@ class OrderController extends AuthController
|
|
|
$order_sn = build_sn($order['id']);
|
|
|
Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
|
|
|
//保存订单患者信息
|
|
|
- $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number'])->where('id', $req['patient_id'])->first()->getOriginal();
|
|
|
+ $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url'])->where('id', $req['patient_id'])->first()->getOriginal();
|
|
|
$addPatient['order_id'] = $order['id'];
|
|
|
$addPatient['patient_id'] = $req['patient_id'];
|
|
|
if ($req['product_type'] == 1) {
|
| xqd
@@ -139,6 +144,8 @@ class OrderController extends AuthController
|
|
|
//改变用户余额
|
|
|
$change_amount = 0 - $payment_amount;
|
|
|
User::changeBalance($user['id'], $change_amount, 1, $order['id'], '咨询订单消费');
|
|
|
+
|
|
|
+ Order::payCompletedHandle($order['id']);
|
|
|
}
|
|
|
}
|
|
|
|
| xqd
@@ -170,8 +177,13 @@ class OrderController extends AuthController
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
|
|
- if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
|
|
|
- return out(null, 10001, '密码错误');
|
|
|
+ if (!empty($req['pay_password'])) {
|
|
|
+ if (empty($user['pay_password'])) {
|
|
|
+ return out(null, 60010, '未设置支付密码');
|
|
|
+ }
|
|
|
+ if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
|
|
|
+ return out(null, 10001, '密码错误');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$product_type = $req['product_type'];
|
| xqd
@@ -228,7 +240,7 @@ class OrderController extends AuthController
|
|
|
$order_sn = build_sn($order['id']);
|
|
|
Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
|
|
|
//保存订单患者信息
|
|
|
- $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number'])->where('id', $req['patient_id'])->first()->getOriginal();
|
|
|
+ $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url'])->where('id', $req['patient_id'])->first()->getOriginal();
|
|
|
$addPatient['order_id'] = $order['id'];
|
|
|
$addPatient['patient_id'] = $req['patient_id'];
|
|
|
$addPatient['organization_id'] = $req['organization_id'];
|
| xqd
@@ -292,6 +304,8 @@ class OrderController extends AuthController
|
|
|
//改变用户余额
|
|
|
$change_amount = 0 - $payment_amount;
|
|
|
User::changeBalance($user['id'], $change_amount, 1, $order['id'], '预约订单消费');
|
|
|
+
|
|
|
+ Order::payCompletedHandle($order['id']);
|
|
|
}
|
|
|
}
|
|
|
|
| xqd
@@ -320,8 +334,13 @@ class OrderController extends AuthController
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
|
|
- if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
|
|
|
- return out(null, 10001, '密码错误');
|
|
|
+ if (!empty($req['pay_password'])) {
|
|
|
+ if (empty($user['pay_password'])) {
|
|
|
+ return out(null, 60010, '未设置支付密码');
|
|
|
+ }
|
|
|
+ if (sha1(md5($req['pay_password'])) !== $user['pay_password']) {
|
|
|
+ return out(null, 10001, '密码错误');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$discount_amount = 0;
|
| xqd
@@ -329,6 +348,12 @@ class OrderController extends AuthController
|
|
|
//计算优惠金额
|
|
|
$discount_amount = UserCoupon::getDiscountAmount($req['user_coupon_id'], $user['id'], $req['total_amount'], 6);
|
|
|
}
|
|
|
+
|
|
|
+ $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url'])->where('id', $req['patient_id'])->first()->getOriginal();
|
|
|
+ if (empty($addPatient['card_img_url'])) {
|
|
|
+ return out(null, 70011, '该患者未上传身份证');
|
|
|
+ }
|
|
|
+
|
|
|
$payment_amount = $req['total_amount'] - $discount_amount;
|
|
|
$payment_amount = $payment_amount < 0 ? 0 : $payment_amount;
|
|
|
|
| xqd
@@ -365,12 +390,11 @@ class OrderController extends AuthController
|
|
|
$order_sn = build_sn($order['id']);
|
|
|
Order::where('id', $order['id'])->update(['order_sn' => $order_sn]);
|
|
|
//保存订单患者信息
|
|
|
- $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number'])->where('id', $req['patient_id'])->first()->getOriginal();
|
|
|
$addPatient['order_id'] = $order['id'];
|
|
|
$addPatient['patient_id'] = $req['patient_id'];
|
|
|
OrderPatient::create($addPatient);
|
|
|
//保存订单服务包表
|
|
|
- $addPack = ServicePack::select(['id as service_pack_id', 'name as pack_name', 'intro as pack_intro', 'price as pack_price', 'insurance_policy', 'team_id', 'phone_minutes', 'chat_num', 'appoint_num', 'vaccine_limit_amount', 'nurses_limit_amount', 'effective_days'])->where('id', $req['service_pack_id'])->first()->getOriginal();
|
|
|
+ $addPack = ServicePack::select(['id as service_pack_id', 'name as pack_name', 'intro as pack_intro', 'price as pack_price', 'insurance_policy', 'insurance_img_url', 'team_id', 'phone_minutes', 'chat_num', 'appoint_num', 'vaccine_limit_amount', 'nurses_limit_amount', 'effective_days'])->where('id', $req['service_pack_id'])->first()->getOriginal();
|
|
|
$addPack['order_id'] = $order['id'];
|
|
|
$addPack['is_security'] = $req['is_security'];
|
|
|
$addPack['guardian_name'] = $req['guardian_name'];
|
| xqd
@@ -416,6 +440,8 @@ class OrderController extends AuthController
|
|
|
//改变用户余额
|
|
|
$change_amount = 0 - $payment_amount;
|
|
|
User::changeBalance($user['id'], $change_amount, 1, $order['id'], '购买服务包');
|
|
|
+
|
|
|
+ Order::payCompletedHandle($order['id']);
|
|
|
}
|
|
|
}
|
|
|
|
| xqd
@@ -435,7 +461,8 @@ class OrderController extends AuthController
|
|
|
'list_type' => 'required|in:0,1,2',
|
|
|
'product_type' => 'integer',
|
|
|
'order_status' => 'integer',
|
|
|
- 'time_sort' => 'in:0,1'
|
|
|
+ 'time_sort' => 'in:0,1',
|
|
|
+ 'is_pack_expire' => 'in:0,1,2',
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
| xqd
@@ -452,10 +479,24 @@ class OrderController extends AuthController
|
|
|
$builder->whereIn('product_type', [3,4,5]);
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ $builder->where('product_type', '<', 7);
|
|
|
+ }
|
|
|
}
|
|
|
if (!empty($req['order_status'])) {
|
|
|
$builder->where('order_status', $req['order_status']);
|
|
|
}
|
|
|
+ if (!empty($req['is_pack_expire'])) {
|
|
|
+ $tmpBuilder = OrderPack::join('orders as o', 'o.id', '=', 'order_packs.order_id')->where('o.user_id', $user['id']);
|
|
|
+ if ($req['is_pack_expire'] == 1) {
|
|
|
+ $tmpBuilder->where('order_packs.end_time', '<', time());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $tmpBuilder->where('order_packs.end_time', '>=', time());
|
|
|
+ }
|
|
|
+ $order_ids = $tmpBuilder->pluck('o.id')->toArray();
|
|
|
+ $builder->whereIn('id', $order_ids);
|
|
|
+ }
|
|
|
if (!empty($req['time_sort'])) {
|
|
|
$builder->orderBy('id', 'desc');
|
|
|
}
|
| xqd
@@ -476,7 +517,7 @@ class OrderController extends AuthController
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
|
|
- $data = Order::with(['docter.office', 'docter.qualification', 'orderPatient', 'orderPack', 'orderNurse', 'orderVaccine', 'organization.docter'])->where('id', $req['order_id'])->where('user_id', $user['id'])->first();
|
|
|
+ $data = Order::with(['docter.office', 'docter.qualification', 'orderPatient', 'orderPack.team.docter', 'orderNurse', 'orderVaccine', 'organization.docter'])->where('id', $req['order_id'])->where('user_id', $user['id'])->first();
|
|
|
|
|
|
return out($data);
|
|
|
}
|