鹿和sa0ChunLuyu 1 year ago
commit 83810d049b

@ -210,7 +210,7 @@ class AspNetZhuanController extends Controller
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 1000);
$table->string('request_url', 2000);
$table->timestamps();
});
}

@ -367,10 +367,14 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
}
}
if(isset($wj_flag) and $wj_flag==1){
$item_price=$item_price*$wj_zhekou;
$item_price=number_format($item_price*$wj_zhekou, 2, '.', '') ;
}
//使用优惠券
if(isset($coupon_id) and !empty($coupon_id)){
if($item_price==0) return \Yz::echoError1("自选项目金额为0无需使用优惠券");
$item_price=$this->useYouHuiQuan($item_price,$person,$coupon_id);
}
$items_info['price'] =number_format($item_price, 2, '.', '') ;
$items_info['price'] =$item_price;
$items_info['original_price'] = $items_original_price;
foreach ($groupedData as $keshiName => $children) {
$items_info['items'][] = [
@ -463,57 +467,7 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
];
}
$env=config('app.globals.Env');
//如果使用了代金券
if(isset($coupon_id) and !empty($coupon_id)){
if($true_price==0) return \Yz::echoError1("无需使用代金券");
$quanInfo=false;
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$data=[
'ghzid'=>$person->ghzid,
'action'=>1,
];
$YouHuiQuanList=$AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key=>$quan){
if($quan['DZJID']==$coupon_id){
$quanInfo=$quan;
}
}
if(!!$quanInfo and $quanInfo['是否在有效内']===true and $quanInfo['TimeNuZTTextm']=="有效" and $quanInfo['ZT']==1){
}else{
return \Yz::echoError1("此代金券不可用");
}
$quanType=false;
$YouHuiQuanType=$AspNet::YouHuiQuan(['action'=>2]);
foreach ($YouHuiQuanType as $key=>$type){
if($quanInfo['DZJLBID']==$type['DZJLBID']){
$quanType=$type;
}
// if($type['TJXCXHX']==1 and ($type['MKJE']===0 || $type['MKJE']>=$true_price)){
// $YouHuiQuanType_ids[]=$type['DZJLBID'];
// }
}
if($quanType===false or $quanInfo===false) return \Yz::echoError1("此代金券不可用");
if($quanType['TJXCXHX']!=1 ) return \Yz::echoError1("此代金券不可用");
if($quanType['MKJE']==0 or $quanType['MKJE']>=$true_price){
//抵扣代金券金额
if($quanType['YHLX']==1){//抵扣券
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
}
if($quanType['YHLX']==2){//抵扣券
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
}
}
}
}
$data = [
@ -643,6 +597,7 @@ select combo_id as c_id,count(*) as count from orders where status in(2,4) group
return \Yz::Return(true, "查询完成", ['combos' => $list]);
}
function jaccard_similarity($set1, $set2) {
// 计算交集
$intersection = array_intersect($set1, $set2);
@ -655,4 +610,58 @@ select combo_id as c_id,count(*) as count from orders where status in(2,4) group
// 返回Jaccard相似度
return count($intersection) / count($union);
}
//使用优惠券
public function useYouHuiQuan($true_price,$person,$coupon_id){
$env=config('app.globals.Env');
//如果使用了代金券
if(isset($coupon_id) and !empty($coupon_id)){
if($true_price==0) return \Yz::echoError1("无需使用代金券");
$quanInfo=false;
if($env=='pro') { //如果是正式环境
$AspNet=new AspNetZhuanController();
$data=[
'ghzid'=>$person->ghzid,
'action'=>1,
];
$YouHuiQuanList=$AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key=>$quan){
if($quan['DZJID']==$coupon_id){
$quanInfo=$quan;
}
}
if(!!$quanInfo and $quanInfo['是否在有效内']===true and $quanInfo['TimeNuZTTextm']=="有效" and $quanInfo['ZT']==1){
}else{
return \Yz::echoError1("此代金券不可用");
}
$quanType=false;
$YouHuiQuanType=$AspNet::YouHuiQuan(['action'=>2]);
foreach ($YouHuiQuanType as $key=>$type){
if($quanInfo['DZJLBID']==$type['DZJLBID']){
$quanType=$type;
}
// if($type['TJXCXHX']==1 and ($type['MKJE']===0 || $type['MKJE']>=$true_price)){
// $YouHuiQuanType_ids[]=$type['DZJLBID'];
// }
}
if($quanType===false or $quanInfo===false) return \Yz::echoError1("此代金券不可用");
if($quanType['TJXCXHX']!=1 ) return \Yz::echoError1("此代金券不可用");
if($quanType['MKJE']==0 or $quanType['MKJE']>=$true_price){
//抵扣代金券金额
if($quanType['YHLX']==1){//抵扣券
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
}
if($quanType['YHLX']==2){//抵扣券
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
}
}
}
return $true_price;
}
}
}

@ -114,6 +114,7 @@ class OrderController extends Controller
if (!$person) return \Yz::echoError1('体检人不存在');
$title = "自选项目";
$price = 0;
$quanInfo=false;
$true_price = 0;//订单真实支付金额
$buy_info = [
'combo' => [
@ -208,6 +209,14 @@ class OrderController extends Controller
if (isset($wj_flag) and $wj_flag == 1) {
$item_price = $item_price * $wj_zhekou;
}
//使用优惠券
if (isset($coupon_id) and !empty($coupon_id)) {
if($item_price==0) return \Yz::echoError1("自选项目金额为0无需使用优惠券");
$use_quan=$this->useYouHuiQuan($item_price,$person,$coupon_id);
$quanInfo=$use_quan['quanInfo'];
$item_price=$use_quan['price'];
}
$price += $item_price;
$missingIds = array_diff($item_ids, $existingIds);
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用Id:" . implode(', ', $missingIds));
@ -341,53 +350,7 @@ class OrderController extends Controller
if ($true_price < -1) return \Yz::echoError1("");
if ($true_price < 0) $true_price = 0;
//如果使用了代金券
$quanInfo = false;
if (isset($coupon_id) and !empty($coupon_id)) {
if ($true_price == 0) return \Yz::echoError1("无需使用代金券");
$AspNet = new AspNetZhuanController();
$data = [
'ghzid' => $person->ghzid,
'action' => 1,
];
$YouHuiQuanList = $AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key => $quan) {
if ($quan['DZJID'] == $coupon_id) {
$quanInfo = $quan;
}
}
if ($quanInfo['是否在有效内'] === true and $quanInfo['TimeNuZTTextm'] == "有效" and $quanInfo['ZT'] == 1) {
} else {
return \Yz::echoError1("此代金券不可用");
}
$quanType = false;
$YouHuiQuanType = $AspNet::YouHuiQuan(['action' => 2]);
foreach ($YouHuiQuanType as $key => $qtype) {
if ($quanInfo['DZJLBID'] == $qtype['DZJLBID']) {
$quanType = $qtype;
}
// if($qtype['TJXCXHX']==1 and ($qtype['MKJE']===0 || $qtype['MKJE']>=$true_price)){
// $YouHuiQuanType_ids[]=$qtype['DZJLBID'];
// }
}
if ($quanType === false or $quanInfo === false) return \Yz::echoError1("此代金券不可用");
if ($quanType['TJXCXHX'] != 1) return \Yz::echoError1("此代金券不可用");
if ($quanType['MKJE'] == 0 or $quanType['MKJE'] >= $true_price) {
//抵扣代金券金额
if($quanType['YHLX']==1){//抵扣券
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
}
if($quanType['YHLX']==2){//抵扣券
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
}
}
}
if (isset($plan_nmr_info) and !empty($plan_nmr_info)) {
$plan_nmr_temp = [];
foreach ($plan_nmr_info as $key => $plan_nmr) {
@ -640,6 +603,7 @@ class OrderController extends Controller
}
//如果是个检
if ($order_info->type == 1) {
$checkup_type=DB::table('checkup_type')->where(['id' => $order_info->checkup_type_id])->first();
$cad = [
'type' => 1,
"姓名" => $order_info->name,
@ -651,7 +615,7 @@ class OrderController extends Controller
"预约时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
"介绍人" => $order_info->referral,
'套餐Id' => $order_info->combo_id == 0 ? null : $order_info->combo_id,
'体检类型Id'=>isset($checkup_type->sx_id)?$checkup_type->sx_id:null,
"已收费" => true,
];
@ -821,4 +785,54 @@ class OrderController extends Controller
$info = $peis::Post($url_code, $hospital, $data);
return $info;
}
public function useYouHuiQuan($true_price,$person,$coupon_id){
//如果使用了代金券
$quanInfo = false;
if (isset($coupon_id) and !empty($coupon_id)) {
if ($true_price == 0) return \Yz::echoError1("无需使用代金券");
$AspNet = new AspNetZhuanController();
$data = [
'ghzid' => $person->ghzid,
'action' => 1,
];
$YouHuiQuanList = $AspNet::YouHuiQuan($data);
foreach ($YouHuiQuanList as $key => $quan) {
if ($quan['DZJID'] == $coupon_id) {
$quanInfo = $quan;
}
}
if ($quanInfo['是否在有效内'] === true and $quanInfo['TimeNuZTTextm'] == "有效" and $quanInfo['ZT'] == 1) {
} else {
return \Yz::echoError1("此代金券不可用");
}
$quanType = false;
$YouHuiQuanType = $AspNet::YouHuiQuan(['action' => 2]);
foreach ($YouHuiQuanType as $key => $qtype) {
if ($quanInfo['DZJLBID'] == $qtype['DZJLBID']) {
$quanType = $qtype;
}
// if($qtype['TJXCXHX']==1 and ($qtype['MKJE']===0 || $qtype['MKJE']>=$true_price)){
// $YouHuiQuanType_ids[]=$qtype['DZJLBID'];
// }
}
if ($quanType === false or $quanInfo === false) return \Yz::echoError1("此代金券不可用");
if ($quanType['TJXCXHX'] != 1) return \Yz::echoError1("此代金券不可用");
if ($quanType['MKJE'] == 0 or $quanType['MKJE'] >= $true_price) {
//抵扣代金券金额
if($quanType['YHLX']==1){//抵扣券
$true_price=($true_price-$quanInfo['JE'])>0 ? $true_price-$quanInfo['JE']:0;
}
if($quanType['YHLX']==2){//抵扣券
$true_price=number_format($true_price*$quanType['DZBL'],2, '.', '');
}
}
}
return ['price'=>$true_price,'quanInfo'=>$quanInfo];
}
}

@ -37,7 +37,7 @@ class PlanController extends Controller
if(!$plan) return \Yz::echoError1("该号源不存在");
if($plan->status<>1) return \Yz::echoError1("该号源不已被占用,请重新选择");
$u=DB::table('plans')->where(['id',$id,'status'=>1])->update(['status'=>2]);
$u=DB::table('plans')->where(['id'=>$id,'status'=>1])->update(['status'=>2]);
if($u){
return \Yz::Return(true,'操作成功',[]);
}else{

@ -67,7 +67,7 @@ class SiXinPushController extends Controller
$table->string('mark', 50)->index();
$table->longText('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->string('request_url', 2000);
$table->timestamps();
});
}

@ -190,7 +190,7 @@ class PEISApiController extends Controller
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->string('request_url', 2000);
$table->timestamps();
});
}

@ -97,7 +97,7 @@ class XCXApiController extends Controller
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->string('request_url', 2000);
$table->timestamps();
});
}

@ -13,7 +13,7 @@ class TestController extends Controller
public function DBtest(){
echo DB::table('users')->count();
// $order= new OrderService();
// dd($order->DepartmentItemCount(33));
// dd($order->DepartmentItemCount(147));
$aspnet=new AspNetZhuanController();

@ -99,7 +99,7 @@ class LogService
$table->text('get_data');
$table->text('header_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->string('request_url', 2000);
$table->string('create_time', 30);
$table->string('update_time', 30);
$table->timestamps();

@ -2,6 +2,7 @@
namespace App\Services;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\API\PEISApiController;
use Illuminate\Support\Facades\DB;
class OrderService
@ -12,6 +13,15 @@ class OrderService
{
$order=DB::table('orders')->where('id',$id)->first();
if(!$order) return ['status'=>false,'msg'=>'订单不存在'];
$wait_day=false;
if(isset($order->tj_number) and !empty($order->tj_number)){
$peis = new PEISApiController();
$wait=$peis::Get($peis::Api('报告时间计算',"2403020020"),"111111","报告时间计算");
if(isset($wait['Data']['预计所需天数'])){
$wait_day=$wait['Data']['预计所需天数'];
}
}
$buy_info=json_decode($order->buy_info,true);
$list=[];
$drop_ids = ['519', '603'];
@ -72,7 +82,7 @@ class OrderService
'count'=>count($item),
];
}
return ['department_list'=>$de_list,'wait_day'=>"10"];
return ['department_list'=>$de_list,'wait_day'=>$wait_day];
}
public function Cancel($orderInfo)

@ -51,6 +51,19 @@ const configRef = (e) => {
if (!config_ref.value) {
config_ref.value = e;
mountedAction();
uni.showModal({
title: '提示',
content: '优惠券仅可用于抵扣自选项目金额',
showCancel:false,
confirmText:'确定',
success: function (res) {
if (res.confirm) {
} else if (res.cancel) {
}
}
});
}
};

@ -281,7 +281,7 @@
</view>
</view>
</view>
<view class="botm_blank_wrapper" style="font-size: 18rpx;color: #ccc;">10302313</view>
<view class="botm_blank_wrapper" style="font-size: 18rpx;color: #ccc;">10312335</view>
</view>
</view>
</template>

Loading…
Cancel
Save