model = new Shop(); } /** * 获取店铺实例 */ public function find() { $shopInfo = $this->model->where([['site_id', '=', $this->site_id]])->findOrEmpty(); return $shopInfo; } /** * 获取店铺信息 */ public function getInfo():array { $shopInfo = $this->model ->with([ 'categoryName' ]) ->where([['site_id', '=', $this->site_id]])->findOrEmpty()->toArray(); if (!empty($shopInfo)) { $withdrawal_money = floatval($shopInfo['money_get'] - $shopInfo['money'] - $shopInfo['money_cash_outing'] ?? 0); $shopInfo['withdrawal_money'] = number_format($withdrawal_money,2,'.',''); $settlement_money = 0; $settlement_array = event('ShopWaitSettlement', ['site_id' => $this->site_id]); if(!empty($settlement_array)) { foreach ($settlement_array as $k => $v) { $settlement_money += $v; } } $shopInfo['settlement_money'] = number_format($settlement_money,2,'.',''); } return $shopInfo; } /** * 店铺收款方式编辑 */ public function edit(array $data) { $shop_info = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray(); if(empty($shop_info)) return true; $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->update($data); return true; } /** * 检查店铺配置信息是否完善 * @return bool */ public function check() { $shop_info = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray(); if (empty($shop_info)) { return false; } else { if ($shop_info['bank_type'] == 1) { if(empty($shop_info['bank_account_name']) || empty($shop_info['bank_account_no']) || empty($shop_info['bank_name']) || empty($shop_info['bank_address'])) return false; } if ($shop_info['bank_type'] == 2) { if(empty($shop_info['alipay_name']) || empty($shop_info['alipay_account_no'])) return false; } } return true; } }