diff --git a/app/Model/OrderProduct.php b/app/Model/OrderProduct.php index d091b4d..f2e975c 100644 --- a/app/Model/OrderProduct.php +++ b/app/Model/OrderProduct.php @@ -163,6 +163,7 @@ class OrderProduct extends Model "OrderProductItem:product_item_id,order_product_id,product_id,product_name,amount,manufacturer,product_cover_img,product_spec", ]) ->where($params) + ->orderBy("created_at",'desc') ->paginate($per_page, $fields, "page", $page); $data = array(); diff --git a/app/Services/LoginService.php b/app/Services/LoginService.php index f8d6ce9..4e0ea55 100644 --- a/app/Services/LoginService.php +++ b/app/Services/LoginService.php @@ -104,15 +104,6 @@ class LoginService extends BaseService return fail(HttpEnumCode::SERVER_ERROR); } $client_user_id = $user_patient['patient_id']; - - // 发放用户优惠卷 - $CouponService = new CouponService(); - - $res = $CouponService->DistributeCoupon(1,$user->user_id,$user_patient['patient_id']); - if (!$res){ - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR); - } } elseif ($user['user_type'] == 2) { // 新增医生表 $user_doctor = UserDoctorModel::addUserDoctor($data); @@ -128,6 +119,17 @@ class LoginService extends BaseService $account = new Account(); // 创建单个账号 $account->createAccount($user->user_id,$user->user_name,addAliyunOssWebsite($avatar)); + + if ($user['user_type'] == 1){ + // 发放用户优惠卷 + $CouponService = new CouponService(); + + $res = $CouponService->DistributeCoupon(1,$user->user_id,$user_patient['patient_id']); + if (!$res){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + } } else { // 已注册用户 // 重复注册不同端 @@ -318,15 +320,6 @@ class LoginService extends BaseService return fail(HttpEnumCode::SERVER_ERROR); } $client_user_id = $user_patient['patient_id']; - - // 发放用户优惠卷 - $CouponService = new CouponService(); - - $res = $CouponService->DistributeCoupon(1,$user->user_id,$user_patient['patient_id']); - if (!$res){ - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR); - } } elseif ($user['user_type'] == 2) { // 新增医生表 $user_doctor = UserDoctorModel::addUserDoctor($data); @@ -347,6 +340,17 @@ class LoginService extends BaseService $account = new Account(); // 创建单个账号 $account->createAccount($user->user_id,$user->user_name,addAliyunOssWebsite($avatar)); + + if ($user['user_type'] == 1){ + // 发放用户优惠卷 + $CouponService = new CouponService(); + + $res = $CouponService->DistributeCoupon(1,$user->user_id,$user_patient['patient_id']); + if (!$res){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + } } else { // 已注册用户 if ($user_type != $user['user_type']) {