isAjax()) { if ($this->AgentInfo) { $data = [ 'is_point_cash' => input('is_point_cash', 0), 'point_cash_rate' => input('point_cash_rate', 0), 'point_use_rate' => input('point_use_rate', 0), 'isisp_year_fee' => input('isisp_year_fee', 0), 'store_open' => input('store_open', 0), 'is_member_settled' => input('is_member_settled', 0), 'settled_condition' => input('settled_condition', 0), 'consume_count' => input('consume_count', 0), 'consume_money' => input('consume_money', 0), 'goods_ids' => input('goods_ids', 0), 'consume_condition' => input('consume_condition', 0), 'settlement_type' => input('settlement_type', 0), 'is_open' => input('is_open', 0), 'is_invite' => input('is_invite', 0), 'district_money' => input('district_money', 0), 'use_settle_number' => input('use_settle_number', 0), 'aliAppId' => input('aliAppId', ''), 'weAppId' => input('weAppId', ''), ]; $cron = new Cron(); $condition = [ 'event' => 'SaasCronOrderSettlement', 'relate_id' => $this->site_id ]; $cron->deleteCron($condition); if ($data['is_open'] == 1) { switch ($data['settlement_type']) { case 'week': $period = 2; break; case 'month': $period = 3; break; } $cron->addCron(2, $period, '佣金结算', 'SaasCronOrderSettlement', time(), $this->site_id); } $res = $model->setBasicsConfig($data, $this->site_id); return $res; } else { return error(-1, '您还不是代理商'); } } $this->forthMenu(); $this->assign('info', $this->AgentInfo); $this->assign('goods_list', ['goods_list' => []]); $basics = $model->getBasicsConfig($this->site_id); if ($basics['data']['value']['settled_condition'] == 4) { // 购买指定商品 $goods_model = new GoodsModel(); $condition[] = ['goods_id', 'in', $basics['data']['value']['goods_ids']]; $condition[] = ['site_id', '=', $this->site_id]; $goods_list = $goods_model->getGoodsList($condition, 'goods_id,goods_name,goods_image,price,goods_stock'); if (!empty($goods_list)) { $this->assign('goods_list', $goods_list['data']); } } $this->assign("basics_info", $basics['data']['value']); return $this->fetch('basics/setiing'); } public function promoteRule() { $document_model = new Document(); if (request()->isAjax()) { $content = input('content', ''); $res = $document_model->setDocument('入驻推广规则', $content, [['site_id', '=', $this->site_id], ['app_module', '=', 'shop'], ['document_key', '=', "SAAS_PROMOTE_RULE"]]); return $res; } else { $document = $document_model->getDocument([['site_id', '=', $this->site_id], ['app_module', '=', 'shop'], ['document_key', '=', "SAAS_PROMOTE_RULE"]]); $this->assign('document', $document['data']); $this->forthMenu(); return $this->fetch('basics/promote_rule'); } } /** * 结算设置 */ public function settlement() { $model = new ConfigModel(); if (request()->isAjax()) { if (empty(input('transfer_type'))) { $transfer_type = ''; } else { $transfer_type = implode(',', input('transfer_type')); } $data = [ 'account_type' => input('account_type', ''),//佣金计算方式 'settlement_day' => input('settlement_day', ''),//天数 'withdraw' => input('withdraw', ''),//最低提现额度 'withdraw_rate' => input('withdraw_rate', ''),//佣金提现手续费 'min_no_fee' => input('min_no_fee', 0),//最低免手续费区间 'max_no_fee' => input('max_no_fee', 0),//最高免手续费区间 'withdraw_status' => input('withdraw_status', ''),//提现审核 'withdraw_type' => input('withdraw_type', ''),//提现方式, 'transfer_type' => $transfer_type,//转账方式, 'is_auto_transfer' => input('is_auto_transfer', 0),//是否自动转账 1 手动转账 2 自动转账 'is_invoice' => input('is_invoice', 0),//是否索要发票 'invoice_title' => input('invoice_title', ''),//是否索要发票 'invoice_taxid' => input('invoice_taxid', ''),//是否索要发票 'invoice_service' => input('invoice_service', 0),//是否索要发票 'min' => input('min', 0),//提现最低额度 'max' => input('max', 0),//提现最高额度 'time_week' => input('time_week', []),//提现最高额度 ]; $res = $model->setSettlementConfig($data, 1, $this->site_id); return $res; } else { $withdraw_config = $model->getWithdrawConfig($this->site_id)['data']['value'] ?? []; $this->assign('withdraw_info', $withdraw_config); $fenxiao_withdraw_model = new ManageWithdraw(); $transfer_type_list = $fenxiao_withdraw_model->getTransferType($this->site_id); $transfer_type_list['balance'] = '余额'; $this->assign('transfer_type_list', $transfer_type_list); $this->forthMenu(); return $this->fetch('config/settlement'); } } /*** * 商家管理端小程序 * @return void */ public function mini() { $model = new ConfigModel(); $config = $model->getMiniConfig($this->site_id)['data']['value']; $service_version = config('alipay.managetemplate'); $app = new MinCode($this->site_id); if (request()->isAjax()) { $type = input('type'); $custom_version = input('custom_version'); $aliApp = new AliPayApplet($this->site_id, $config); $appInfo = $aliApp->publishingInit($type, $custom_version); if ($appInfo['code'] == 0) { $data = [ 'app_version' => $custom_version, 'create_time' => date('Y-m-d H:i:s'), 'version_status' => 'INIT', 'version_description' => '发布新版本', ]; cache('alipay_mini_version_' . $this->site_id, $data, 600); $config['old_version'] = $config['service_version'] ?? ''; $config['service_version'] = $service_version['template_version']; $config['custom_version'] = $custom_version; return $model->setMiniConfig($config, $this->site_id); } return $appInfo; } $is_auth = false; $isnew_version = false; $app_version_infos = []; $auth_img = ''; if (empty($config)) { $is_auth = false; $url = addon_url('aliapp://shop/auth/authinfo'); $text = $this->site_id . '|saas|' . $this->AgentInfo['agent_pid']; $auth_url = (new MinCode())->getminiAuthorizationUrl($url, url_safe_base64_encode($text)); $qrcode_name = $this->site_id . 'alipay_auth'; $path = 'upload/qrcode'; qrcode($auth_url, $path, $qrcode_name); $auth_img = '/' . $path . '/' . $qrcode_name . '.png'; } else if ($config['line_type'] == 'auth') { $params = [ 'bundle_id' => $service_version['bundle_id'], 'version_status' => 'RELEASE,WAIT_RELEASE,AUDITING,INIT', ]; $result = $app->requestApi('alipay.open.mini.version.list.query', $params); $result = $result['alipay_open_mini_version_list_query_response']; $app_version_infos = $result['app_version_infos'] ?? []; $app_app_versions = $result['app_versions'] ?? []; $temp = cache('alipay_mini_version_' . $this->site_id); if ($temp) { if (!in_array($temp['app_version'], array_column($app_version_infos, 'app_version'))) { $app_version_infos = array_merge([$temp], $app_version_infos); } } $app_version = current($app_app_versions); if ($app_version) { $config['custom_version'] = incrementVersion($app_version); } else { if (empty($config['custom_version']) || $config['custom_version'] == '') { $config['custom_version'] = $service_version['template_version']; } else { $config['custom_version'] = incrementVersion($config['custom_version']); } } $is_auth = true; if (isset($config['old_version']) && isset($config['service_version'])) { $isnew_version = version_compare($config['service_version'], $config['old_version'], '>'); } } $this->assign('isnew_version', $isnew_version); $this->assign('info', $config); $this->assign('auth_img', $auth_img); $this->assign('miniversion', $app_version_infos); $this->assign('service_version', $service_version); $this->assign('is_auth', $is_auth); $this->forthMenu(); return $this->fetch('basics/mini'); } /*** * 操作方式 * @return array|void */ public function miniListing() { if (request()->isAjax()) { $model = new ConfigModel(); $config = $model->getMiniConfig($this->site_id)['data']['value']; $type = input('type'); $app_version = input('app_version'); $aliApp = new AliPayApplet($this->site_id, $config); $appInfo = $aliApp->publishingInit($type, $app_version); if ($appInfo['code'] == 0) { if ($type == 'delete') { cache('alipay_mini_version_' . $this->site_id, null); } return success(0, '成功'); } else { return error(-1, '操作失败'); } } } }