162 lines
5.1 KiB
PHP
Executable File
162 lines
5.1 KiB
PHP
Executable File
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeshop开源商城系统
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||
// | github下载:https://github.com/likeshop-github
|
||
// | 访问官网:https://www.likeshop.cn
|
||
// | 访问社区:https://home.likeshop.cn
|
||
// | 访问手册:http://doc.likeshop.cn
|
||
// | 微信公众号:likeshop技术社区
|
||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||
// | likeshop团队版权所有并拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeshop.cn.team
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\admin\controller\finance;
|
||
|
||
use app\common\basics\AdminBase;
|
||
use app\admin\logic\finance\FinanceLogic;
|
||
use app\common\model\order\Order as OrderModel;
|
||
use app\admin\logic\finance\CardLogic;
|
||
use app\common\server\JsonServer;
|
||
use think\facade\View;
|
||
use think\facade\Db;
|
||
|
||
/**
|
||
* 卡密
|
||
* Class Finance
|
||
* @package app\admin\controller\finance
|
||
*/
|
||
class Card extends AdminBase
|
||
{
|
||
public function lists()
|
||
{
|
||
|
||
if ($this->request->isAjax()) {
|
||
|
||
$get = $this->request->get();
|
||
$data = CardLogic::lists($get);
|
||
//var_dump($data);
|
||
return JsonServer::success('', $data, 1);
|
||
}
|
||
|
||
// 配送方式
|
||
$today = [
|
||
date('Y-m-d H:i:s', strtotime(date("Y-m-d", time()))),
|
||
date('Y-m-d H:i:s', strtotime(date("Y-m-d", time())) + 86399)
|
||
];
|
||
|
||
$yesterday = [
|
||
date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-1 day")))),
|
||
date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-1 day"))) + 86399)
|
||
];
|
||
|
||
|
||
$days_ago7 = [
|
||
date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-7 day")))),
|
||
date('Y-m-d 23:59:59', time())
|
||
];
|
||
|
||
$days_ago30 = [
|
||
date('Y-m-d 00:00:00', strtotime("-30 day")),
|
||
date('Y-m-d 23:59:59', time())
|
||
];
|
||
return view('', [
|
||
'today' => $today,
|
||
'yesterday' => $yesterday,
|
||
'days_ago7' => $days_ago7,
|
||
'days_ago30' => $days_ago30,
|
||
]);
|
||
}
|
||
|
||
public function del(){
|
||
$id = $this->request->request("id");
|
||
$result = Db::name("card")->where(["id"=>$id])->delete();
|
||
if($result){
|
||
return JsonServer::success('删除成功');
|
||
}
|
||
|
||
}
|
||
|
||
public function mdelete(){
|
||
|
||
$ids = $this->request->request("ids");
|
||
$result = Db::name("card")->where("id","in",$ids)->delete();
|
||
if($result){
|
||
return JsonServer::success('删除成功');
|
||
}
|
||
|
||
}
|
||
|
||
public function edit(){
|
||
if($this->request->isAjax()){
|
||
$post = $this->request->post();
|
||
$result = CardLogic::edit($post);
|
||
if($result === true) {
|
||
return JsonServer::success('编辑成功');
|
||
}
|
||
return JsonServer::error(CardLogic::getError());
|
||
}
|
||
|
||
$id = $this->request->get('id', '', 'intval');
|
||
$detail = CardLogic::getCard($id);
|
||
|
||
return view('', [
|
||
'info' => $detail,
|
||
]);
|
||
|
||
}
|
||
|
||
public function cardImport(){
|
||
|
||
$file = $_FILES['file']['tmp_name'];
|
||
//var_dump($get);die();
|
||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
|
||
$reader->setReadDataOnly(TRUE);
|
||
$spreadsheet = $reader->load($file); //载入excel表格
|
||
|
||
|
||
$worksheet = $spreadsheet->getActiveSheet();
|
||
$highestRow = $worksheet->getHighestRow(); // 总行数
|
||
$highestColumn = $worksheet->getHighestColumn(); // 总列数
|
||
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn); // e.g. 5
|
||
|
||
$lines = $highestRow - 3;
|
||
if ($lines <= 0) {
|
||
exit('Excel表格中没有数据');
|
||
}
|
||
|
||
$data = [];
|
||
//$nums = 0;
|
||
for ($row = 4; $row <= $highestRow; ++$row) {
|
||
$data_temp = [];
|
||
$data_temp["card_number"] = $worksheet->getCellByColumnAndRow(2, $row)->getValue(); //卡号
|
||
$data_temp["card_secret"] = $worksheet->getCellByColumnAndRow(4, $row)->getValue(); //密钥
|
||
$data_temp["money"] = $worksheet->getCellByColumnAndRow(5, $row)->getValue(); //面额
|
||
$data_temp["status"] = 0;
|
||
$data_temp["create_time"] = time();
|
||
$data_temp["update_time"] = time();
|
||
$data[] = $data_temp;
|
||
//$nums++;
|
||
|
||
}
|
||
//var_dump($data_temp);
|
||
$result = Db::name("card")->insertAll($data,true);
|
||
//var_dump(Db::name("card")->getLastSql());
|
||
if($result){
|
||
return JsonServer::success('成功导入'.count($data).'条数据!');
|
||
}else{
|
||
exit('数据导入失败');
|
||
}
|
||
//var_dump($data);
|
||
|
||
|
||
|
||
|
||
}
|
||
} |