|
@@ -229,15 +229,25 @@ class CardController
|
|
|
public function user_card_details(Request $request,$id)
|
|
|
{
|
|
|
if (!$id) return app('json')->fail('传入id');
|
|
|
- $list = UserEquity::alias('a')
|
|
|
- ->field('a.*,b.name')
|
|
|
- ->leftJoin('diagnosis_cate b', 'a.c_id = b.id')
|
|
|
- ->where('a.user_card_id', $id)
|
|
|
- ->where('a.uid', $request->uid())
|
|
|
- ->select();
|
|
|
- if (count($list) == 0) return app('json')->fail('优惠卡未使用');
|
|
|
-
|
|
|
- $list = count($list) > 0 ? $list->toArray() : [];
|
|
|
+ $list = UserCard::where('id', $id)
|
|
|
+ ->where('uid', $request->uid())
|
|
|
+ ->find();
|
|
|
+ if (!$list) return app('json')->fail('优惠卡不存在');
|
|
|
+ $list = $list->toArray();
|
|
|
+ $list['cards'] = [];
|
|
|
+ if ($list['status'] == 1){
|
|
|
+ $card = UserEquity::where('user_card_id', $id)->select();
|
|
|
+ foreach ($card as &$item){
|
|
|
+ $item['name'] = implode(',', DiagnosisCate::where('id', 'in', $item['c_id'])->column('name'));
|
|
|
+ $list['cards'][] = $item;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $card = CardProject::where('card_id', $list['card_id'])->select();
|
|
|
+ foreach ($card as $item){
|
|
|
+ $item['name'] = implode(',', DiagnosisCate::where('id', 'in', $item['c_id'])->column('name'));
|
|
|
+ $list['cards'][] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return app('json')->successful($list);
|
|
|
|