| xqd
@@ -8,7 +8,6 @@
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
-use App\Models\Docter;
|
|
|
use App\Models\Nurse;
|
|
|
use App\Models\Order;
|
|
|
use App\Models\OrderNurse;
|
| xqd
@@ -17,7 +16,6 @@ use App\Models\OrderPatient;
|
|
|
use App\Models\OrderVaccine;
|
|
|
use App\Models\Patient;
|
|
|
use App\Models\Payment;
|
|
|
-use App\Models\SchedulePeriod;
|
|
|
use App\Models\ServicePack;
|
|
|
use App\Models\Team;
|
|
|
use App\Models\TimePeriod;
|
| xqd
@@ -70,6 +68,11 @@ class OrderController extends AuthController
|
|
|
return out(null, 10011, '请输入支付密码');
|
|
|
}
|
|
|
|
|
|
+ //图文咨询订单未结束时不能针对同一医生再次下图文订单
|
|
|
+ if ($req['product_type'] == 2 && Order::where('docter_id', $req['docter_id'])->whereIn('order_status', [2,3])->exists()) {
|
|
|
+ return out(null, 10012, '您已经下过该医生的图文订单了,并且订单还未完成');
|
|
|
+ }
|
|
|
+
|
|
|
if ($req['payment_type'] == 2) {
|
|
|
if ($user['balance'] < $payment_amount) {
|
|
|
return out(null, 601, '余额不足');
|
| xqd
@@ -77,7 +80,7 @@ class OrderController extends AuthController
|
|
|
}
|
|
|
|
|
|
if ($req['payment_type'] == 3) {
|
|
|
- OrderPack::checkUserServicePack($req['order_pack_id'], $user['id'], $req['payment_type'], $payment_amount);
|
|
|
+ OrderPack::checkUserServicePack($req['order_pack_id'], $user['id'], $req['product_type'], $payment_amount);
|
|
|
}
|
|
|
|
|
|
$order_status = $payment_status = 1;
|
| xqd
@@ -168,6 +171,11 @@ class OrderController extends AuthController
|
|
|
Order::payCompletedHandle($order['id']);
|
|
|
}
|
|
|
|
|
|
+ //如果有优惠券就标记优惠券为已使用
|
|
|
+ if (!empty($req['user_coupon_id'])) {
|
|
|
+ UserCoupon::where('id', $req['user_coupon_id'])->update(['order_id' => $order['id'], 'status' => 2, 'use_time' => time()]);
|
|
|
+ }
|
|
|
+
|
|
|
DB::commit();
|
|
|
} catch (Exception $e) {
|
|
|
DB::rollBack();
|
| xqd
@@ -236,7 +244,7 @@ class OrderController extends AuthController
|
|
|
}
|
|
|
|
|
|
if ($req['payment_type'] == 3) {
|
|
|
- OrderPack::checkUserServicePack($req['order_pack_id'], $user['id'], $req['payment_type'], $payment_amount);
|
|
|
+ OrderPack::checkUserServicePack($req['order_pack_id'], $user['id'], $req['product_type'], $payment_amount);
|
|
|
}
|
|
|
|
|
|
$order_status = $payment_status = 1;
|
| xqd
@@ -343,6 +351,11 @@ class OrderController extends AuthController
|
|
|
Order::payCompletedHandle($order['id']);
|
|
|
}
|
|
|
|
|
|
+ //如果有优惠券就标记优惠券为已使用
|
|
|
+ if (!empty($req['user_coupon_id'])) {
|
|
|
+ UserCoupon::where('id', $req['user_coupon_id'])->update(['order_id' => $order['id'], 'status' => 2, 'use_time' => time()]);
|
|
|
+ }
|
|
|
+
|
|
|
DB::commit();
|
|
|
} catch (Exception $e) {
|
|
|
DB::rollBack();
|
| xqd
@@ -487,11 +500,18 @@ class OrderController extends AuthController
|
|
|
//改变用户余额
|
|
|
$change_amount = 0 - $payment_amount;
|
|
|
User::changeBalance($user['id'], $change_amount, 1, $order['id'], '购买服务包');
|
|
|
-
|
|
|
- Order::payCompletedHandle($order['id']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if ($payment_amount == 0 || $req['payment_type'] == 2) {
|
|
|
+ Order::payCompletedHandle($order['id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果有优惠券就标记优惠券为已使用
|
|
|
+ if (!empty($req['user_coupon_id'])) {
|
|
|
+ UserCoupon::where('id', $req['user_coupon_id'])->update(['order_id' => $order['id'], 'status' => 2, 'use_time' => time()]);
|
|
|
+ }
|
|
|
+
|
|
|
DB::commit();
|
|
|
} catch (Exception $e) {
|
|
|
DB::rollBack();
|