|
|
|
|
@ -521,10 +521,9 @@ class OrderNewController extends Controller
|
|
|
|
|
public function ZhuanZeng()
|
|
|
|
|
{
|
|
|
|
|
$order_id = request('order_id');
|
|
|
|
|
$person_id = request('person_id');
|
|
|
|
|
$person = request('person_info');
|
|
|
|
|
$openid = request('openid');
|
|
|
|
|
$person=DB::table('web_user_person')->where(['id'=>$person_id,'is_del'=>0])->first();
|
|
|
|
|
if(!$person) return \Yz::echoError1('转赠用户不存在');
|
|
|
|
|
if(!isset($person)) return \Yz::echoError1("转赠人不能为空");
|
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
|
|
|
|
|
if (!$user) return \Yz::echoError1('用户不存在');
|
|
|
|
|
$order = DB::table('orders')
|
|
|
|
|
@ -540,7 +539,7 @@ class OrderNewController extends Controller
|
|
|
|
|
})->first();
|
|
|
|
|
if(!$order) return \Yz::echoError1('此订单无法转赠他人');
|
|
|
|
|
if($order->web_user_id<>$user->id) return \Yz::echoError1('无权操作此订单');
|
|
|
|
|
if($order->person_id==$person_id) return \Yz::echoError1('被转赠人不能和原用户相同');
|
|
|
|
|
if($order->id_number==$person['ID_No']) return \Yz::echoError1('被转赠人不能和原用户相同');
|
|
|
|
|
//查询转赠码表是否生成了对应的转赠码
|
|
|
|
|
$transfer_code=DB::table('transfer_code')->where(['link_order_id'=>$order->id,'is_del'=>0])->first();
|
|
|
|
|
if(!!$transfer_code) return \Yz::echoError1('此订单已生成转赠码,无法再次转赠');
|
|
|
|
|
@ -552,7 +551,7 @@ class OrderNewController extends Controller
|
|
|
|
|
if($comboDetail_sex=='全部') $comboDetail_sex=0;
|
|
|
|
|
if($comboDetail_sex=='男') $comboDetail_sex=1;
|
|
|
|
|
if($comboDetail_sex=='女') $comboDetail_sex=2;
|
|
|
|
|
if($comboDetail_sex <> 0 and $comboDetail_sex <> $person->sex) return \Yz::echoError1('性别不符,此套餐不适合转赠给此用户');
|
|
|
|
|
if($comboDetail_sex <> 0 and $comboDetail_sex <> $person['Patsexid']) return \Yz::echoError1('性别不符,此套餐不适合转赠给此用户');
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
$now_datetime=date('Y-m-d H:i:s');
|
|
|
|
|
@ -563,8 +562,8 @@ class OrderNewController extends Controller
|
|
|
|
|
'web_user_id' => 0,
|
|
|
|
|
'checkup_type_id' => $order->checkup_type_id,
|
|
|
|
|
'person_id' => 0,
|
|
|
|
|
'name' => $person->name,
|
|
|
|
|
'id_number' => $person->id_number,
|
|
|
|
|
'name' => $person['Patname'],
|
|
|
|
|
'id_number' => $person['ID_No'],
|
|
|
|
|
'buy_info' => $order->buy_info,
|
|
|
|
|
'price' => $order->price,
|
|
|
|
|
'true_price' =>$order->true_price,
|
|
|
|
|
@ -573,10 +572,10 @@ class OrderNewController extends Controller
|
|
|
|
|
'erxian_appointment_info' => $order->erxian_appointment_info,
|
|
|
|
|
'combo_id' => $order->combo_id,
|
|
|
|
|
'hospital_id' => $order->hospital_id,
|
|
|
|
|
'phone' => $person->phone,
|
|
|
|
|
'sex' => $person->sex,
|
|
|
|
|
'birthday' => $person->birthday,
|
|
|
|
|
'married' => $person->married,
|
|
|
|
|
'phone' => $person['Fixphone'],
|
|
|
|
|
'sex' => $person['Patsexid'],
|
|
|
|
|
'birthday' => $this->formatDate($person['Patbdate']),
|
|
|
|
|
'married' => 0,
|
|
|
|
|
'created_at' => $now_datetime,
|
|
|
|
|
'paycheck_time' => $now_datetime
|
|
|
|
|
];
|
|
|
|
|
@ -633,4 +632,12 @@ class OrderNewController extends Controller
|
|
|
|
|
|
|
|
|
|
return $orderNumber;
|
|
|
|
|
}
|
|
|
|
|
function formatDate($dateString) {
|
|
|
|
|
$dateTime = DateTime::createFromFormat('Y/n/j G:i:s', $dateString);
|
|
|
|
|
// 检查是否有错误发生
|
|
|
|
|
if (!$dateTime || $dateTime->format('Y/n/j G:i:s') !== $dateString) {
|
|
|
|
|
return "1900-01-01";
|
|
|
|
|
}
|
|
|
|
|
return $dateTime->format('Y-m-d');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|