zilong 4 år sedan
förälder
incheckning
6d317672cd

+ 1 - 0
.gitignore

xqd
@@ -11,3 +11,4 @@ Homestead.yaml
 npm-debug.log
 yarn-error.log
 .idea/
+.DS_Store

+ 25 - 9
app/Http/Controllers/Api/V1/OrderController.php

xqd xqd xqd xqd xqd xqd 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;
@@ -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'])->where('id', $req['patient_id'])->first()->getOriginal();
             $addPatient['order_id'] = $order['id'];
             $addPatient['patient_id'] = $req['patient_id'];
             if ($req['product_type'] == 1) {
@@ -172,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'];
@@ -230,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'])->where('id', $req['patient_id'])->first()->getOriginal();
             $addPatient['order_id'] = $order['id'];
             $addPatient['patient_id'] = $req['patient_id'];
             $addPatient['organization_id'] = $req['organization_id'];
@@ -324,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;
@@ -333,6 +348,7 @@ class OrderController extends AuthController
             //计算优惠金额
             $discount_amount = UserCoupon::getDiscountAmount($req['user_coupon_id'], $user['id'], $req['total_amount'], 6);
         }
+
         $payment_amount = $req['total_amount'] - $discount_amount;
         $payment_amount = $payment_amount < 0 ? 0 : $payment_amount;
 
@@ -369,7 +385,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'])->where('id', $req['patient_id'])->first()->getOriginal();
             $addPatient['order_id'] = $order['id'];
             $addPatient['patient_id'] = $req['patient_id'];
             OrderPatient::create($addPatient);

+ 25 - 2
app/Http/Controllers/Api/V1/PatientController.php

xqd xqd
@@ -23,8 +23,9 @@ class PatientController extends AuthController
             'birthday' => 'required|date',
             'relationship_type' => 'required|integer',
             'info' => 'max:1000',
-            'card_type' => 'required|in:1,2',
-            'card_number' => 'required|max:50',
+            'card_type' => 'in:0,1,2',
+            'card_number' => 'max:50',
+            'card_img_url' => 'url'
         ]);
         $user = $this->user;
 
@@ -34,6 +35,28 @@ class PatientController extends AuthController
         return out();
     }
 
+    public function updatePatient()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'id' => 'required|integer',
+            'name' => 'required|max:50',
+            'sex' => 'required|in:1,2',
+            'avatar' => 'required|url',
+            'birthday' => 'required|date',
+            'relationship_type' => 'required|integer',
+            'info' => 'max:1000',
+            'card_type' => 'in:0,1,2',
+            'card_number' => 'max:50',
+            'card_img_url' => 'url'
+        ]);
+        $user = $this->user;
+
+        Patient::where('id', $req['id'])->where('user_id', $user['id'])->update($req);
+
+        return out();
+    }
+
     public function patientList()
     {
         $user = $this->user;