123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\service\admin\shop\site;
- use app\model\shop\Shop;
- use core\base\BaseAdminService;
- /**
- * 店铺服务层
- * Class ShopService
- * @package addon\mall\app\service\admin\shop\shop
- */
- class ShopAccountService extends BaseAdminService
- {
- public function __construct()
- {
- parent::__construct();
- $this->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;
- }
- }
|