getMerchantList($condition, 25, 'mchid desc'); $merchant_state_text = ['使用中', '已禁用']; Tpl::output('merchant_state_text', $merchant_state_text); Tpl::output('merchant_list', $merchant_list); Tpl::output('page', $model_merchant->showpage('2')); Tpl::showpage('merchant.index'); } public function changeStateOp() { $mchid = intval($_GET['mchid']); $state = intval($_GET['state']); $model_merchant = Model('merchant'); $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]); if (empty($merchant_info) || !in_array($state, [1, 2])) { showMessage('操作成功', 'index.php?act=merchant&op=merchant'); } $resp = $model_merchant->editMerchant(['merchant_state' => $state], ['mchid' => $mchid]); if (!$resp) { showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error'); } showMessage('操作成功', 'index.php?act=merchant&op=merchant'); } /** * 新增机构 */ public function merchant_addOp() { if (chksubmit()) { /** * 验证 */ $obj_validate = new Validator(); $obj_validate->validateparam = [ ["input" => $_POST["name"], "require" => "true", "message" => '机构账号不能为空'], ["input" => $_POST["company_name"], "require" => "true", "message" => '机构公司名称不能为空'], ["input" => $_POST["password"], "require" => "true", "message" => '密码不能为空'] ]; $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $name = trim($_POST['name']); $company_name = trim($_POST['company_name']); $pwd = trim($_POST['password']); $alarm_amount = $_POST['alarm_amount'] ?? 0; $model_merchant = Model('merchant'); $model_member = Model('member'); try { $trans = new trans_wapper($model_merchant, __METHOD__); $insert_member['member_name'] = md5($name . time()); $insert_member['member_passwd'] = $pwd; $insert_id = $model_member->addMember($insert_member); if ($insert_id == false) { $trans->rollback(); showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error'); } $insert_array['name'] = $name; $insert_array['company_name'] = $company_name; $insert_array['org_pwd'] = $pwd; $insert_array['password'] = md5($pwd); $insert_array['admin_id'] = trim($insert_id); $insert_array['alarm_amount'] = $alarm_amount; $result = $model_merchant->addMerchant($insert_array); if ($result) { $url = [ [ 'url' => 'index.php?act=merchant&op=merchant', 'msg' => '返回机构列表', ], [ 'url' => 'index.php?act=merchant&op=merchant_add', 'msg' => '继续新增机构', ], ]; $this->log('添加机构:' . '[ ' . $_POST['name'] . ']', 1); showMessage('机构添加成功', $url); } else { showMessage('机构添加失败'); } $trans->commit(); showMessage('操作成功', 'index.php?act=merchant&op=merchant'); } catch (Exception $e) { $trans->rollback(); showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error'); } } } Tpl::showpage('merchant.add'); } public function merchant_editOp() { $mchid = $_GET['mchid'] ?? $_POST['mchid']; $model_merchant = Model('merchant'); $merchant = $model_merchant->getMerchantInfo(['mchid' => $mchid]); if(empty($merchant)){ showMessage('机构信息有误'); } if (chksubmit()) { $update['company_name'] = trim($_POST['company_name']); $update['org_pwd'] = trim($_POST['password']); $update['password'] = md5($update['org_pwd']); $update['alarm_amount'] = $_POST['alarm_amount'] ?? 0; $result = $model_merchant->editMerchant($update,['mchid' => $mchid]); if ($result) { $this->log('编辑机构:' . '[ ' . $merchant['name'] . ']', 1); showMessage('机构编辑成功', 'index.php?act=merchant&op=merchant'); } else { showMessage('机构添加失败', 'index.php?act=merchant&op=merchant'); } } Tpl::output('merchant', $merchant); Tpl::showpage('merchant.edit'); } public function priceOp() { if (chksubmit()) { $mchid = $_POST['mchid']; //合并表单数据 $card_types = $_POST['cardtype']; $specs = $_POST['spec']; $prices = $_POST['price']; $order_limit = $_POST['order_limit']; foreach ($card_types as $key => $card_type) { $data['card_type'] = $card_type; $data['spec'] = intval($specs[$key]); $data['price'] = ncPriceFormat($prices[$key]); $data['order_limit'] = $order_limit[$key]; $params[] = $data; } foreach ($params as $param) { if($param['price'] > 0) { $insert['mchid'] = $mchid; $insert['spec'] = $param['spec']; $insert['price'] = $param['price']; $insert['card_types'] = $param['card_type']; $insert['order_limit'] = $param['order_limit']; $inserts[] = $insert; } } if(empty($inserts)) { showMessage('操作成功', 'index.php?act=merchant&op=merchant'); } try { $model_merchant = Model('merchant'); $trans = new trans_wapper($model_merchant, __METHOD__); //删除旧费率 $model_merchant->delPrices($mchid); //更新新费率 $model_merchant->insertPrices($inserts); $trans->commit(); showMessage('操作成功', 'index.php?act=merchant&op=merchant'); } catch (Exception $e) { $trans->rollback(); showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error'); } } $mchid = $_GET['mchid'] ?? 0; $goods = $this->GoodsFormat($mchid); Tpl::output('goods', $goods); Tpl::showpage('merchant.price'); } public function getPriceOp() { $mchid = $_GET['mchid'] ?? 0; $model_merchant = Model('merchant'); $items = $model_merchant->table('merchant_price')->where(['mchid' => $mchid])->select(); $check = true; if (empty($items)) { $check = false; } $goods = $this->GoodsFormat($mchid); echo json_encode(['check' => $check, 'data' => $goods]); } private function GoodsFormat($mchid) { $all_spector = function () { global $config; $refill_specs = $config['refill_specs']; $all_type_specs = []; foreach ($refill_specs as $scard_type => $specs) { if ($scard_type == 'petrochina') { //中石油 $card_type = 1; } elseif ($scard_type == 'sinopec') { //中石化 $card_type = 2; } elseif ($scard_type == 'chinamobile') { //中国移动 $card_type = 4; } elseif ($scard_type == 'chinaunicom') { //中国联通 $card_type = 5; } elseif ($scard_type == 'chinatelecom') { //中国电信 $card_type = 6; } else { continue; } $all_type_specs[$card_type] = $specs; } $result =[]; foreach ($all_type_specs as $card_type => $specs) { foreach ($specs as $spec){ $result["{$card_type}-{$spec}"] = ['card_type' => $card_type , 'spec' => $spec]; } } return $result; }; $merch_spector = function ($mchid) { $model_merchant = Model('merchant'); $items = $model_merchant->table('merchant_price')->where(['mchid' => $mchid])->select(); $result = []; foreach ($items as $item) { $card_types = explode(',' , $item['card_types']); foreach ($card_types as $card_type) { $value['spec'] = intval($item['spec']); $result["{$card_type}-{$value['spec']}"] = ['card_type'=>$card_type, 'spec' => intval($item['spec']), 'order_limit' => $item['order_limit'], 'price' => $item['price']]; } } return $result; }; $all_cardtype_specs = $all_spector(); $merch_cardtype_specs = $merch_spector($mchid); $merger = function ($all_specs,$mech_specs) { $result = []; foreach ($all_specs as $cardtype_spec => $value) { $card_name = $this->scard_type($value['card_type']); $data = []; $data['goods_name'] = $card_name; $data['card_type'] = $value['card_type']; $data['spec'] = $value['spec']; if(array_key_exists($cardtype_spec , $mech_specs)) { $data['price'] = $mech_specs[$cardtype_spec]['price']; $data['order_limit'] = $mech_specs[$cardtype_spec]['order_limit']; } else { $data['order_limit'] = -1; $data['price'] = 0; } $result[] = $data; } return $result; }; $result = $merger($all_cardtype_specs,$merch_cardtype_specs); return $result; } public function check_merchantOp() { $mchid = trim($_GET['mchid']); if (!$mchid) { echo ''; die; } $model_merchant = Model('merchant'); $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], '*'); if (empty($merchant_info)) { echo ''; die; } echo 'true'; } /** * ajax操作 */ public function ajaxOp() { $model_merchant = Model('merchant'); switch ($_GET['branch']) { /** * 验证机构名称是否重复 */ case 'check_mch_name': $condition['name'] = $_GET['name']; $list = $model_merchant->getMerchantInfo($condition); if (empty($list)) { echo 'true'; } else { echo 'false'; } exit; /** * 验证机构是否存在 */ case 'check_merchant': $condition['mchid'] = intval($_GET['mchid']); $list = $model_merchant->getMerchantInfo($condition); if (!empty($list)) { echo 'true'; } else { echo 'false'; } exit; } } /** * 充值申请列表 */ public function refill_evidenceOp() { $model_merchant = Model('merchant'); $condition = []; if (trim($_GET['mch_name']) != '') { $condition['mch_name'] = array('like', '%' . $_GET['mch_name'] . '%'); Tpl::output('mch_name', $_GET['mch_name']); } $state_sel = intval($_REQUEST['state_sel']); if ($state_sel == 1) { $condition['check_time'] = 0; $condition['status'] = 1; } elseif ($state_sel == 2) { $condition['check_time'] = ['gt', 0]; $condition['status'] = 2; } elseif ($state_sel == 3) { $condition['check_time'] = ['gt', 0]; $condition['status'] = 3; } else { } //充值申请列表 $evidence_list = $model_merchant->getRefillEvidence($condition, 20, '*', 'add_time desc'); $status_text = ['申请中', '已通过', '已驳回']; $operation_text = ['未预存', '已预存']; Tpl::output('evidence_list', $evidence_list); Tpl::output('status_text', $status_text); Tpl::output('operation_text', $operation_text); Tpl::output('page', $model_merchant->showpage('2')); Tpl::showpage('merchant.refill.evidence_list'); } public function check_evidenceOp() { $status = $_GET['status']; $apply_id = intval($_GET['apply_id']); if ($apply_id > 0) { $model_merchant = Model('merchant'); $evidence_info = $model_merchant->getRefillEvidenceInfo(['apply_id' => $apply_id], '*'); if (empty($evidence_info)) { showMessage('充值申请不存在'); } if ($status == 'pass') { $model_merchant->editRefillEvidence(['apply_id' => $apply_id], ['status' => 2, 'check_time' => time()]); } elseif ($status == 'unpass') { $model_merchant->editRefillEvidence(['apply_id' => $apply_id], ['status' => 3, 'check_time' => time()]); } else { } } showMessage(L('nc_common_save_succ'), urlAdmin('merchant', 'refill_evidence')); } public function rechargeOp() { if (chksubmit()) { $this->add_money(); } else { $apply_id = $_GET['apply_id']; if (!empty($apply_id)) { $model_merchant = Model('merchant'); $evidence_info = $model_merchant->getRefillEvidenceInfo(['apply_id' => $apply_id], '*'); Tpl::output('apply_id', $apply_id); Tpl::output('amount', $evidence_info['amount']); } Tpl::showpage('recharge.add'); } } public function add_money() { $obj_validate = new Validator(); $obj_validate->validateparam = array( array("input" => $_POST["apply_id"], "require" => "true", "message" => Language::get('admin_points_member_error_again')), array("input" => $_POST["pointsnum"], "require" => "true", 'validator' => 'Compare', 'operator' => ' >= ', 'to' => 1, "message" => Language::get('admin_points_points_min_error')) ); $error = $obj_validate->validate(); if ($error != '') { showMessage($error, '', '', 'error'); } $money = abs(floatval($_POST['pointsnum'])); $memo = trim($_POST['pointsdesc']); if ($money <= 0) { showMessage('输入的金额必需大于0', '', 'html', 'error'); } $apply_id = intval($_POST['apply_id']); $model_merchant = Model('merchant'); $evidence_info = $model_merchant->getRefillEvidenceInfo(['apply_id' => $apply_id], '*'); if (!is_array($evidence_info) || count($evidence_info) <= 0) { showMessage("无效的充值申请信息", "index.php?act=merchant&op=recharge&apply_id={$apply_id}", '', 'error'); } if ($evidence_info['status'] != 2) { showMessage("该充值申请未被审核通过", "index.php?act=merchant&op=recharge&apply_id={$apply_id}", '', 'error'); } if ($evidence_info['is_operation'] == 2) { showMessage("该充值申请未已被预存过", "index.php?act=merchant&op=recharge&apply_id={$apply_id}", '', 'error'); } //查询会员信息 $obj_member = Model('member'); $member_id = intval($evidence_info['member_id']); $member_info = $obj_member->getMemberInfo(array('member_id' => $member_id)); $available_predeposit = floatval($member_info['available_predeposit']); $freeze_predeposit = floatval($member_info['freeze_predeposit']); if ($_POST['operatetype'] == 2 && $money > $available_predeposit) { showMessage(('预存款不足,会员当前预存款') . $available_predeposit, 'index.php?act=predeposit&op=predeposit_add', '', 'error'); } if ($_POST['operatetype'] == 3 && $money > $available_predeposit) { showMessage(('可冻结预存款不足,会员当前预存款') . $available_predeposit, 'index.php?act=predeposit&op=predeposit_add', '', 'error'); } if ($_POST['operatetype'] == 4 && $money > $freeze_predeposit) { showMessage(('可恢复冻结预存款不足,会员当前冻结预存款') . $freeze_predeposit, 'index.php?act=predeposit&op=predeposit_add', '', 'error'); } $model_pd = Model('predeposit'); $order_sn = $apply_id; $admininfo = $this->getAdminInfo(); $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款,金额为" . $money . ",编号为" . $order_sn; $admin_act = 'sys_add_money'; switch ($_POST['operatetype']) { case 1: $admin_act = "sys_add_money"; $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【增加】,金额为" . $money . ",编号为" . $order_sn; break; case 2: $admin_act = "sys_del_money"; $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【减少】,金额为" . $money . ",编号为" . $order_sn; break; case 3: $admin_act = "sys_freeze_money"; $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【冻结】,金额为" . $money . ",编号为" . $order_sn; break; case 4: $admin_act = "sys_unfreeze_money"; $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【解冻】,金额为" . $money . ",编号为" . $order_sn; break; default: showMessage('操作失败', 'index.php?act=predeposit&op=pd_log_list'); break; } try { $trans = new trans_wapper($model_pd, __METHOD__); //扣除冻结的预存款 $data = array(); $data['member_id'] = $member_info['member_id']; $data['member_name'] = $member_info['member_name']; $data['amount'] = $money; $data['order_sn'] = $order_sn; $data['admin_name'] = $admininfo['name']; $data['pdr_sn'] = $order_sn; $data['lg_desc'] = $memo; $model_pd->changePd($admin_act, $data); $model_merchant->editRefillEvidence(['apply_id' => $apply_id], ['is_operation' => 2]); $trans->commit(); $this->log($log_msg, 1); showMessage('操作成功', 'index.php?act=merchant&op=refill_evidence'); } catch (Exception $e) { $trans->rollback(); $this->log($log_msg, 0); showMessage($e->getMessage(), 'index.php?act=merchant&op=refill_evidence', 'html', 'error'); } } public function checkevidenceOp() { $apply_id = trim($_GET['apply_id']); if (!$apply_id) { echo ''; die; } $model_merchant = Model('merchant'); $evidence_info = $model_merchant->getRefillEvidenceInfo(['apply_id' => $apply_id], '*'); if (empty($evidence_info)) { echo ''; die; } echo 'true'; } public function refill_orderOp() { $model_refill_order = Model('refill_order'); $condition['inner_status'] = 0; if (!empty($_GET['order_sn'])) { $condition['refill_order.order_sn'] = $_GET['order_sn']; } if (!empty($_GET['mchid'])) { $condition['refill_order.mchid'] = $_GET['mchid']; } if (!empty($_GET['card_type'])) { $condition['refill_order.card_type'] = $_GET['card_type']; } if (!empty($_GET['ch_trade_no'])) { $condition['refill_order.ch_trade_no'] = $_GET['ch_trade_no']; } if (!empty($_GET['card_no'])) { $condition['refill_order.card_no'] = $_GET['card_no']; } if (in_array($_GET['order_state'], array('0', '10', '20', '30', '40'))) { $condition['vr_order.order_state'] = $_GET['order_state']; } $if_start_time = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $_GET['query_start_time']); $if_end_time = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $_GET['query_end_time']); $start_unixtime = $if_start_time ? strtotime($_GET['query_start_time']) : null; $end_unixtime = $if_end_time ? strtotime($_GET['query_end_time']) : null; if ($start_unixtime || $end_unixtime) { $condition['refill_order.order_time'] = array('time', array($start_unixtime, $end_unixtime)); } $merchant_list = Model('')->table('merchant')->select(); foreach ($merchant_list as $key =>$value) { $merchants[$value['mchid']] = $value; } $order_list = $model_refill_order->getMerchantOrderList($condition, 30, 'refill_order.*,vr_order.order_state'); $stat = Model('')->table('refill_order,vr_order')->join('inner') ->on('refill_order.order_id=vr_order.order_id') ->field('sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts') ->where($condition)->select(); foreach ($order_list as $order_id => $order_info) { $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']); $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name']; if($order_info['notify_time'] > 0) { $order_list[$order_id]['diff_time_text'] = $this->elapse_time($order_info['notify_time'] - $order_info['order_time']); $order_list[$order_id]['diff_time'] = $order_info['notify_time'] - $order_info['order_time']; } else { $order_list[$order_id]['diff_time_text'] = $this->elapse_time(time() - $order_info['order_time']); $order_list[$order_id]['diff_time'] = time() - $order_info['order_time']; } } Tpl::output('stat', $stat[0]); Tpl::output('order_list', $order_list); Tpl::output('show_page', $model_refill_order->showpage()); Tpl::showpage('refill.order.index'); } public function notify_merchantOp() { $order_id = $_GET['order_id']; QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => true]); showMessage('操作成功', 'index.php?act=merchant&op=refill_order'); } public function providerOp() { $this->sync_cfgs(); $provider_model = Model('refill_provider'); $condition = []; if (trim($_GET['name']) != '') { $condition['name'] = ['like', '%' . $_GET['name'] . '%']; Tpl::output('name', $_GET['name']); } if (in_array($_GET['type'], [1, 2])) { $condition['type'] = $_GET['type']; } $provider_list = $provider_model->getProviderList($condition, 25); foreach ($provider_list as $key => $provider) { if(!empty($provider['start_period']) && !empty($provider['end_period'])){ $provider_list[$key]['period'] = $provider['start_period'] . '~' . $provider['end_period']; }else{ $provider_list[$key]['period'] = '全时间段'; } } $opened_text = ['使用中', '已禁用']; $type_text = ['油卡', '手机充值卡']; Tpl::output('opened_text', $opened_text); Tpl::output('type_text', $type_text); Tpl::output('provider_list', $provider_list); Tpl::output('show_page', $provider_model->showpage()); Tpl::showpage('provider.index'); } public function sync_cfgs() { $name_val_cfg = function ($items) { $result = []; foreach ($items as $item) { $name = $item->name(); $result[$name] = $item; } return $result; }; $name_val_row = function ($items) { $result = []; foreach ($items as $item) { $name = $item['name']; $result[$name] = $item; } return $result; }; $match = function ($all,$cur) { $insert = []; foreach ($all as $key => $value) { if(!array_key_exists($key,$cur)) { $insert[] = $key; } } return $insert; }; $inserter = function ($mod,$type,$names) { foreach ($names as $name) { $data = ['name' => $name,'type' => $type]; $mod->insert($data); } }; $providers = refill\RefillFactory::instance()->providers(); $oils = $name_val_cfg($providers['oil']); $phones = $name_val_cfg($providers['phone']); $mod_prov = Model('refill_provider'); $oil_items = $mod_prov->getProviderList(['type' => 1]); $oil_items = $name_val_row($oil_items); $oil_inserts = $match($oils,$oil_items); $phone_items = $mod_prov->getProviderList(['type' => 2]); $phone_items = $name_val_row($phone_items); $phone_inserts = $match($phones,$phone_items); $inserter($mod_prov,1,$oil_inserts); $inserter($mod_prov,2,$phone_inserts); } public function changeProviderStateOp() { $provider_id = intval($_GET['id']); $state = intval($_GET['state']); $provider_model = Model('refill_provider'); $provider_info = $provider_model->getProviderInfo(['provider_id' => $provider_id]); if (empty($provider_info) || !in_array($state, [1, 2])) { showMessage('操作成功', 'index.php?act=merchant&op=provider'); } $resp = $provider_model->editProvider(['opened' => $state], ['provider_id' => $provider_id]); if (!$resp) { showMessage('操作失败', 'index.php?act=merchant&op=provider', 'html', 'error'); } showMessage('操作成功', 'index.php?act=merchant&op=provider'); } /** * 新增通道 */ public function provider_addOp() { $provider_model = Model('refill_provider'); if (chksubmit()) { $params = $_POST; unset($params['form_submit']); $result = $provider_model->addProvider($params); if ($result) { $url = [ [ 'url' => 'index.php?act=merchant&op=provider', 'msg' => '返回通道列表', ], [ 'url' => 'index.php?act=merchant&op=provider_add', 'msg' => '继续新增通道', ], ]; $this->log('添加通道:' . '[ ' . $_POST['name'] . ']', 1); showMessage('通道添加成功', $url); } else { showMessage('通道添加失败'); } } Tpl::showpage('provider.add'); } public function provider_editOp() { $provider_model = Model('refill_provider'); if (chksubmit()) { $provider_id = intval($_POST['provider_id']) ?? ''; $provider = $provider_model->getProviderInfo(['provider_id' => $provider_id]); if (empty($provider)) { showMessage('通道信息有误'); } $params = $_POST; unset($params['form_submit']); if (empty($params)) { showMessage('通道编辑成功', 'index.php?act=merchant&op=provider'); } $result = $provider_model->editProvider($params, ['provider_id' => $provider_id]); if ($result) { $this->log('编辑通道:' . '[ ' . $provider['name'] . ']', 1); showMessage('通道编辑成功', 'index.php?act=merchant&op=provider'); } else { showMessage('通道编辑失败', "index.php?act=merchant&op=provider_edit&id={$provider_id}"); } } $provider_id = intval($_GET['id']) ?? ''; $provider = $provider_model->getProviderInfo(['provider_id' => $provider_id]); if (empty($provider)) { showMessage('通道信息有误'); } $type_text = ['油卡', '手机充值卡']; Tpl::output('type_text', $type_text); Tpl::output('provider', $provider); Tpl::showpage('provider.edit'); } public function provider_delOp() { $provider_model = Model('refill_provider'); $provider_id = intval($_GET['id']) ?? ''; $provider = $provider_model->getProviderInfo(['provider_id' => $provider_id]); if (empty($provider)) { showMessage('通道信息有误'); } $result = $provider_model->delProvider(['provider_id' => $provider_id]); if ($result) { $this->log('删除通道:' . '[ ' . $provider['name'] . ']', 1); showMessage('通道删除成功', 'index.php?act=merchant&op=provider'); } else { showMessage('通道删除失败', "index.php?act=merchant&op=provider"); } } private function scard_type(int $card_type) { if ($card_type == 1) { //中石油 return '中石油'; } elseif ($card_type == 2) { //中石化 return '中石化'; } elseif ($card_type == 4) { //中国移动 return '中国移动'; } elseif ($card_type == 5) { //中国联通 return '中国联通'; } elseif ($card_type == 6) { //中国电信 return '中国电信'; } else { return 'unknown'; } } private function elapse_time($seconds) { $minutes = intval($seconds / 60); $second = intval($seconds % 60); if($minutes > 0){ $result = "{$minutes}分钟{$second}秒"; }else{ $result = "{$second}秒"; } return $result; } }