input('date', ''); if (empty($date)) $date = date('Y-m-01'); if (!strtotime($date)) { return $this->apiResponseError('查询日期不合法'); } $money_type = request()->input('money_type', '1'); if (!in_array($money_type, [3, 1, 2])) { return $this->apiResponseError('资金类型错误'); } $m_id = request()->member['id']; $money = MoneyDetailServer::creatServer()->getMoney($m_id, $money_type); $date_arr = CommonServer::creatServer()->getNextMonth($date); $income_info = MoneyDetailServer::creatServer()->getMoneyIncome($m_id, $money_type, $date_arr); $income_info['money'] = $money; $income_info['date'] = $date; return $this->apiResponseSuccess('获取信息成功', $income_info); } /** * 获取资金流水类型 */ function getWaterType() { $money_type = request()->input('money_type', '1'); if (!in_array($money_type, [3, 1, 2])) { return $this->apiResponseError('资金类型错误'); } $water_type = MoneyDetailServer::creatServer()->getWaterType($money_type); array_unshift($water_type, ['water_key' => '0', 'water_name' => '全部']); return $this->apiResponseSuccess('获取信息成功', $water_type); } /** * 获取流水明细 * @return \Illuminate\Http\JsonResponse */ function getWaterList() { $money_type = request()->input('money_type', '1'); if (!in_array($money_type, [3, 1, 2])) { return $this->apiResponseError('资金类型错误'); } $water_key = request()->input('water_key', ''); $m_id = request()->member['id']; $shop_id = request()->input('shop_id', ''); $where = [['m_id', $m_id], ['type', $money_type]]; if ($water_key) $where[] = ['status', $water_key]; if ($shop_id) $where[] = ['shop_id', $shop_id]; $date = request()->input('date', ''); if (empty($date)) $date = date('Y-m-01'); if (!strtotime($date)) { return $this->apiResponseError('查询日期不合法'); } $date_arr = CommonServer::creatServer()->getNextMonth($date); $list = MoneyDetail::where($where) ->whereBetween('created_at', $date_arr) ->select(['id', 'price', 'status', 'remainder', 'add_reduce', 'created_at', 'mark']) ->orderBy('id', 'desc') ->paginate(20); foreach ($list as $item) { $item->{'status_str'} = MoneyDetailServer::creatServer()->getStatusArr($item->{'status'}); $item->{'price'} =CommonServer::creatServer()->setFormatNum($item->{'price'},2); } return $this->apiResponseSuccess('获取数据成功', ['date' => $date, 'total_num' => $list->total(), 'items' => $list->items()]); } }