diff --git a/app/admin/controller/shop/LocalStore.php b/app/admin/controller/shop/LocalStore.php index 3ac0dad8..086b5cb3 100644 --- a/app/admin/controller/shop/LocalStore.php +++ b/app/admin/controller/shop/LocalStore.php @@ -7,9 +7,9 @@ use app\common\server\ConfigServer; use app\common\enum\LocalLifeICBCEnum; use app\admin\logic\shop\LocalStoreLogic; use app\common\server\JsonServer; -use app\shop\logic\order\InvoiceLogic; use think\facade\Request; + class LocalStore extends AdminBase { public function lists() @@ -47,23 +47,6 @@ class LocalStore extends AdminBase ]); } - /** - * @notes 删除本地生活 - */ - public function del() - { - if ($this->request->isAjax()) { - $id = $this->request->post('id'); - try { - if (LocalStoreLogic::del_data($id)) { - return JsonServer::success('操作成功'); - } - } catch (\Exception $e) { - return JsonServer::error('操作失败'); - } - } - } - /** * @notes 审核操作 */ @@ -74,10 +57,11 @@ class LocalStore extends AdminBase if (in_array($post['state'], LocalStoreLogic::$STATE_ENUM)) { if ($post['state'] == 1) { $data = LocalStoreLogic::get_data($post['id']); - Request::post('https://dlh.hainings.com/shop/abutment/test', [ + $result = Request::post('https://dlh.hainings.com/shop/abutment.abutment/test', [ 'empowerPhone' => $data['empowerPhone'], 'crftNo1' => $data['crftNo1'] ]); + } if (LocalStoreLogic::update_state($post['id'], $post['state'])) { return JsonServer::success('操作成功'); @@ -105,4 +89,20 @@ class LocalStore extends AdminBase } return JsonServer::success('', $result); } + + public function downloadErCode() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + if ($post['lstore_id'] > 0){ + $result = LocalStoreLogic::getPayImage($post['lstore_id']); + if ($result['pay_image']) { + $path = parse_url($result['pay_image'])['path']; + $url = (string)url("index/download/downloadLocalStoreErcodeImage", ['url' => $path], false, true); + return JsonServer::success('', ['url' => $url]); + } + return JsonServer::error('下载失败'); + } + } + } } \ No newline at end of file diff --git a/app/admin/logic/shop/LocalStoreLogic.php b/app/admin/logic/shop/LocalStoreLogic.php index 08d72cec..5d9f86d7 100644 --- a/app/admin/logic/shop/LocalStoreLogic.php +++ b/app/admin/logic/shop/LocalStoreLogic.php @@ -17,7 +17,7 @@ class LocalStoreLogic extends Logic public static function lists() { return array( - 'lists' => LocalStore::where(['del' => 0])->with('info')->select()->toArray() + 'lists' => LocalStore::with('info')->select()->toArray() ); } @@ -31,19 +31,7 @@ class LocalStoreLogic extends Logic return LocalStore::where(['lstore_id' => $id])->update(['store_state' => $state]); } - /** - * @notes 删除本地商家数据 - */ - public static function del_data($id) { - return LocalStore::where(['lstore_id' => $id, 'del' => 0])->update([ - 'del' => 1, - 'del_time' => date('Y-m-d H:i:s') - ]); - } - - /** - * @notes 获取未审核数据 - */ + // 获取未审核数据 public static function get_unaudited_data() { return LocalStore::where(['store_state' => 0])->count(); @@ -100,4 +88,9 @@ class LocalStoreLogic extends Logic return false; } } + + public static function getPayImage($lstore_id) + { + return LocalStore::where('lstore_id', $lstore_id)->field('pay_image')->find()->toArray(); + } } \ No newline at end of file diff --git a/app/admin/view/shop/local_store/order.html b/app/admin/view/shop/local_store/order.html index 7b2c6cec..6f6bd908 100644 --- a/app/admin/view/shop/local_store/order.html +++ b/app/admin/view/shop/local_store/order.html @@ -26,9 +26,8 @@
- @@ -49,8 +48,39 @@ , {field: "tips", width: 300, align: "center", title: "交易附言"} , {field: "notes", width: 300, align: "center", title: "备注"} , {field: "create_time", width: 300, align: "center", title: "创建时间"} + ,{title:"操作", width:200, align:"center", fixed:"right", toolbar:"#table-operation"} ]); + var active = { + download: function(obj) { + like.ajax({ + url: "{:url('shop.LocalStore/downloadErCode')}", + data: obj.data, + type: "POST", + success:function(res) { + if(res.code == 1) { + console.log(res.data.url) + // console.log(123) + // const image = new Image() + // image.src = res.data.pay_image; + // image.onload = function () { + // const link = document.createElement('a') + // link.style.display = 'none' + // document.body.appendChild(link) + // + // link.setAttribute('download', 'erCode.jpg') + // link.setAttribute('href', res.data.pay_image) + // + // link.click() + // } + window.location.href = res.data.url; + } + } + }); + }, + }; + like.eventClick(active); + // 导出 form.on('submit(data-export)', function (data) { var field = data.field; diff --git a/app/index/controller/Download.php b/app/index/controller/Download.php index fe8af016..63f9d34d 100644 --- a/app/index/controller/Download.php +++ b/app/index/controller/Download.php @@ -39,17 +39,20 @@ class Download extends IndexBase //通过文件缓存的key获取文件储存的路径 $exportCache = new ExportCache($fileKey); $fileInfo = $exportCache->getFile($fileKey); - if (empty($fileInfo)) { abort(404, '下载文件不存在'); } //下载前删除缓存 $exportCache->del($fileKey); - return download($fileInfo['src'] . $fileInfo['name'], $fileInfo['name']); } + public function downloadLocalStoreErcodeImage() + { + $url = request()->get('url'); + $path = public_path() . ltrim($url, '/'); - + return download($path, basename($url)); + } } \ No newline at end of file