ShopHotel.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\api\controller\shop;
  3. use app\common\controller\Api;
  4. use app\common\model\HotelModel;
  5. use app\common\model\OfflineShopModel;
  6. use app\common\model\OfflineTypeModel;
  7. use app\utils\DataUtil;
  8. use think\Db;
  9. /**
  10. * 示例接口
  11. */
  12. class ShopHotel extends Api
  13. {
  14. protected $noNeedLogin = [''];
  15. protected $noNeedRight = ['*'];
  16. public function home()
  17. {
  18. $user_id = $this->auth->id;
  19. $model = new HotelModel();
  20. $info = $model->getDetail(
  21. params: ['user_id' => $user_id],
  22. select: ['id','invite_id','user_id','name','image','images','back_rate','address']
  23. );
  24. if (!$info){
  25. return $this->success('未开通门店');
  26. }
  27. // 待核销金额
  28. $wait_use = Db::name('bill')->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order','status'=>2])->field('sum(total_amount - back_amount) as money')->find();
  29. // 已核销
  30. $used = Db::name('bill')->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order','status'=>3])->field('sum(total_amount - back_amount) as money')->find();
  31. // 已退款
  32. $refund = Db::name('bill')->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order','status'=>4])->field('sum(total_amount - back_amount) as money')->find();
  33. $statistics = [
  34. 'wait_use' => $wait_use['money'] ?? 0,
  35. 'used' => $used['money'] ?? 0,
  36. 'refund' => $refund['money'] ?? 0,
  37. ];
  38. return $this->success('success',[
  39. 'info' => $info,
  40. 'statistics' => $statistics
  41. ]);
  42. }
  43. }