getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'SHOP_STORE_WITHDRAW' ] ]); //数据格式化 $data = [ //是否进行门店结算 'is_settlement' => $res[ 'data' ][ 'value' ][ 'is_settlement' ] ?? 0, //结算周期 1 按天 2. 按周 3. 按月 4. 立即结算 'period_type' => $res[ 'data' ][ 'value' ][ 'period_type' ] ?? 4, //结算比率 'settlement_rate' => $res[ 'data' ][ 'value' ][ 'settlement_rate' ] ?? 0, //结算成本控制 cuppon,point,balance,fenxiao_commission 'settlement_cost' => $res[ 'data' ][ 'value' ][ 'settlement_cost' ] ?? '',//'cuppon,point,balance,fenxiao_commission' //是否允许提现 'is_withdraw' => $res[ 'data' ][ 'value' ][ 'is_withdraw' ] ?? 0, //是否提现审核 'is_audit' => $res[ 'data' ][ 'value' ][ 'is_audit' ] ?? 0, //可提现账户类型 wechat,alipay, bank 'withdraw_type' => $res[ 'data' ][ 'value' ][ 'withdraw_type' ] ?? '', 'withdraw_least' => $res[ 'data' ][ 'value' ][ 'withdraw_least' ] ?? 0, // 提现最低金额 ]; $res[ 'data' ][ 'value' ] = $data; return $res; } /** * 门店结算相关设置 */ public function setStoreWithdrawConfig($site_id, $data) { $config = new ConfigModel(); $res = $config->setConfig($data, '门店结算设置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'SHOP_STORE_WITHDRAW' ] ]); $cron = new Cron(); $execute_time = 0; switch ( $data[ 'period_type' ] ) { case 1://天 $date = strtotime(date('Y-m-d 00:00:00')); $execute_time = strtotime('+1day', $date); break; case 2://周 $execute_time = Carbon::parse('next monday')->timestamp; break; case 3://月 $execute_time = Carbon::now()->addMonth()->firstOfMonth()->timestamp; break; } if ($execute_time > 0) { $cron->deleteCron([ [ 'event', '=', 'StoreWithdrawPeriodCalc' ], [ 'relate_id', '=', $site_id ] ]); $cron->addCron('2', '1', '门店周期结算', 'StoreWithdrawPeriodCalc', $execute_time, $site_id, $data[ 'period_type' ]); } return $res; } /** * 获取门店运营相关设置 * @param $site_id */ public function getStoreBusinessConfig($site_id) { $config = new ConfigModel(); $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'SHOP_STORE_BUSINESS' ] ]); //数据格式化 $data = [ //门店运营模式 shop:店铺整体运营 store:连锁门店运营模式 'store_business' => $res[ 'data' ][ 'value' ][ 'store_business' ] ?? 'shop', //是否允许切换门店 'is_allow_change' => $res[ 'data' ][ 'value' ][ 'is_allow_change' ] ?? 1, 'confirm_popup_control' => $res[ 'data' ][ 'value' ][ 'confirm_popup_control' ] ?? 1, // 门店确认弹窗 //门店控制权限 'store_auth' => $res[ 'data' ][ 'value' ][ 'store_auth' ] ?? '',//'config,balance,point,coupon,adjust' ]; $res[ 'data' ][ 'value' ] = $data; return $res; } /** * 门店结算相关设置 */ public function setStoreBusinessConfig($site_id, $data) { $config = new ConfigModel(); $res = $config->setConfig($data, '门店功能设置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'SHOP_STORE_BUSINESS' ] ]); return $res; } /** * addSettlementCron 添加门店结算计划任务 默认为3 - 月 */ public function addSettlementCron($site_id) { $config = new ConfigModel(); $config->setConfig([ 'period_type' => 3 ], '门店结算设置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'SHOP_STORE_WITHDRAW' ] ]); $cron = new Cron(); $execute_time = Carbon::now()->addMonth()->firstOfMonth()->timestamp; $cron->deleteCron([ [ 'event', '=', 'StoreWithdrawPeriodCalc' ], [ 'relate_id', '=', $site_id ] ]); $res = $cron->addCron('2', '1', '门店周期结算', 'StoreWithdrawPeriodCalc', $execute_time, $site_id, 3); return $this->success($res); } }