|
|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|