|
@@ -63,6 +63,7 @@ class Codecreate extends Backend
|
|
|
//pengchanglu
|
|
|
$params['orderid'] = 'c'. date("YmdHis") . mt_rand(100, 999);
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
+ $last_id = $this->model->getLastInsID();
|
|
|
//生成码
|
|
|
/*
|
|
|
$code_temp = [];
|
|
@@ -76,9 +77,9 @@ class Codecreate extends Backend
|
|
|
Db::table('pi_p_code')->insertAll($code_temp);
|
|
|
*/
|
|
|
|
|
|
- $sql = 'INSERT INTO `pig`.`pi_p_code` (`admin_id`, `createtime`) VALUES ';
|
|
|
+ $sql = 'INSERT INTO `pig`.`pi_p_code` (`admin_id`,`co_id`,`createtime`) VALUES ';
|
|
|
for ($i=0; $i < $params['num']; $i++) {
|
|
|
- $sql .= ' ('.$params['admin_id'].','.time().'),';
|
|
|
+ $sql .= ' ('.$params['admin_id'].','.$last_id.','.time().'),';
|
|
|
}
|
|
|
$sql = rtrim($sql, ',');
|
|
|
$sql .= ' ;';
|
|
@@ -112,25 +113,26 @@ class Codecreate extends Backend
|
|
|
public function download()
|
|
|
{
|
|
|
$url = 'http://pig.viicb.com/index/index/code.html?code=';
|
|
|
- $co_id = $params = $this->request->request("co_id");
|
|
|
- if (!$co_id) {
|
|
|
- $this->error('co_id为空!');
|
|
|
+ $ids = $params = $this->request->request("ids");
|
|
|
+ if (!$ids) {
|
|
|
+ $this->error('ids');
|
|
|
}
|
|
|
+ $ids_arr = explode(',', $ids);
|
|
|
$model = new \app\admin\model\pig\Code;
|
|
|
- $list = $model->where('co_id', $co_id)->column('id');
|
|
|
+ $list = $model->where('co_id', 'in', $ids_arr)->column('id');
|
|
|
|
|
|
set_time_limit(0);
|
|
|
ini_set('memory_limit', '512M');
|
|
|
|
|
|
//导出csv格式
|
|
|
header("Content-Type:text/csv");
|
|
|
- header("Content-Disposition:attachment;filename=" . $co_id ."-code-" . date("Y-m-d") . ".csv");
|
|
|
+ header("Content-Disposition:attachment;filename=code-" . date("Y-m-d") . ".csv");
|
|
|
ob_end_clean();
|
|
|
|
|
|
echo 'ID,URL'."\n";
|
|
|
|
|
|
foreach ($list as $k => $v) {
|
|
|
- echo $k+1,','.$url.encrypt(str_pad($v, 8, '0', STR_PAD_LEFT))."\n";
|
|
|
+ echo $k+1,','.$url.encrypt(str_pad($v, 10, '0', STR_PAD_LEFT))."\n";
|
|
|
// code...
|
|
|
}
|
|
|
exit;
|