增加原价字段

wenjuan
yanzai 1 year ago
parent 21e0f21bba
commit 8bb7b2551d

@ -54,6 +54,7 @@ class ItemController extends Controller
'name'=>$item['名称'], 'name'=>$item['名称'],
'pinyin'=>$item['拼音'], 'pinyin'=>$item['拼音'],
'price'=>$item['价格'], 'price'=>$item['价格'],
'original_price'=>$item['价格'],
'is_choose'=>$item['可选']===false ? "0" : "1", 'is_choose'=>$item['可选']===false ? "0" : "1",
'keshi_id'=>$item['科室Id'], 'keshi_id'=>$item['科室Id'],
'keshi_name'=>$item['科室名称'], 'keshi_name'=>$item['科室名称'],

@ -202,6 +202,7 @@ select combo_id as c_id,count(*) as count from orders where status in(2,4) group
$hospital=DB::table('hospitals')->where(['id'=>1,'status'=>1,'is_del'=>0])->first(); $hospital=DB::table('hospitals')->where(['id'=>1,'status'=>1,'is_del'=>0])->first();
$combo_info=[];//套餐信息 $combo_info=[];//套餐信息
$pay_item_count=0;//需自费项目个数 $pay_item_count=0;//需自费项目个数
$all_original_price=0;
if(isset($combo_id)){ if(isset($combo_id)){
// $combo=DB::table('combos')->where(['hospital_id'=>$hospital_id,'combo_id'=>$combo_id,'status'=>1])->first(); // $combo=DB::table('combos')->where(['hospital_id'=>$hospital_id,'combo_id'=>$combo_id,'status'=>1])->first();
$combo=DB::select("select a.*,b.*,c.name as crowd_name from combos as a LEFT JOIN ( $combo=DB::select("select a.*,b.*,c.name as crowd_name from combos as a LEFT JOIN (
@ -233,6 +234,7 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
$combo_info['tags2']=$combo->tags2; $combo_info['tags2']=$combo->tags2;
$combo_info['price']=$combo->price; $combo_info['price']=$combo->price;
$combo_info['original_price']=$combo->original_price; $combo_info['original_price']=$combo->original_price;
$all_original_price+=$combo_info['original_price'];
$combo_items=json_decode($combo->items,true); $combo_items=json_decode($combo->items,true);
$groupedData = []; $groupedData = [];
foreach ($combo_items as $item){ foreach ($combo_items as $item){
@ -253,10 +255,13 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
$items_info=[];//自选项目信息 $items_info=[];//自选项目信息
if(isset($item_ids) and !empty($item_ids)){ if(isset($item_ids) and !empty($item_ids)){
$price=0; $price=0;
$items_original_price=0;
$items=DB::table('items')->whereIn('item_id',$item_ids)->where(['status'=>1])->get(); $items=DB::table('items')->whereIn('item_id',$item_ids)->where(['status'=>1])->get();
$groupedData = []; $groupedData = [];
foreach ($items as $item){ foreach ($items as $item){
$price=$price+$item->price; $price=$price+$item->price;
$all_original_price+=$item->original_price;
$items_original_price+=$item->original_price;
$keshiName = $item->keshi_name; $keshiName = $item->keshi_name;
if (!isset($groupedData[$keshiName])) { if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = []; $groupedData[$keshiName] = [];
@ -264,6 +269,7 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
$groupedData[$keshiName][] = ['desc'=>$item->jianjie,'name'=>$item->name]; $groupedData[$keshiName][] = ['desc'=>$item->jianjie,'name'=>$item->name];
} }
$items_info['price']=$price; $items_info['price']=$price;
$items_info['original_price']=$items_original_price;
foreach ($groupedData as $keshiName => $children) { foreach ($groupedData as $keshiName => $children) {
$items_info['items'][] = [ $items_info['items'][] = [
'keshi_name' => $keshiName, 'keshi_name' => $keshiName,
@ -285,6 +291,7 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
'save_money'=>$save_money, 'save_money'=>$save_money,
'coupon_money'=>$coupon_money, 'coupon_money'=>$coupon_money,
'true_price'=>$true_price,//需要用户支付的金的 'true_price'=>$true_price,//需要用户支付的金的
'original_price'=>$all_original_price,//总原价
'pay_item_count'=>$pay_item_count,//需要付费的项目数量 'pay_item_count'=>$pay_item_count,//需要付费的项目数量
]; ];
return \Yz::Return(true,"查询成功",$data); return \Yz::Return(true,"查询成功",$data);

@ -52,6 +52,7 @@ class ItemController extends Controller
'id' => $item->item_id, 'id' => $item->item_id,
'title' => $item->name, 'title' => $item->name,
'price' =>$item->price, 'price' =>$item->price,
'original_price'=>$item->original_price,
'pinyin' => $item->pinyin, 'pinyin' => $item->pinyin,
]; ];

Loading…
Cancel
Save