123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\adminapi\controller\v1\user\member;
- use app\adminapi\controller\AuthController;
- use app\services\user\member\SecurityCodeRecordServices;
- use app\services\user\member\SecurityCategoryServices;
- use crmeb\services\FileService;
- use think\facade\App;
- /**
- * Class MemberCard
- * @package app\adminapi\controller\v1\user\member
- */
- class SecurityCodeRecord extends AuthController
- {
- /**
- * 初始化service层句柄
- * MemberCard constructor.
- * @param App $app
- * @param MemberCardServices $memberCardServices
- */
- public function __construct(App $app, SecurityCodeRecordServices $securityCodeRecordServices)
- {
- parent::__construct($app);
- $this->services = $securityCodeRecordServices;
- }
- /**
- * 防伪码列表
- * @param $card_batch_id
- * @return mixed
- */
- public function list()
- {
- $where = $this->request->getMore([
- ['category_id', ""],
- ['security_code', ""],
- ['scan_uid', ""],
- ['status', ""],
- ['page', 1],
- ['limit', 20],
- ]);
- $data = $this->services->getSearchList($where);
- return app('json')->success($data);
- }
- /**
- * 会员分类
- * @return mixed
- */
- public function member_ship()
- {
- /** @var MemberShipServices $memberShipService */
- $memberShipService = app()->make(MemberShipServices::class);
- $data = $memberShipService->getSearchList();
- return app('json')->success($data);
- }
- /**
- * 保存
- * @param $id
- * @param MemberShipServices $memberShipServices
- * @return mixed
- */
- public function save($id, SecurityCodeRecordServices $securityCodeRecordServices)
- {
- $data = $this->request->postMore([
- ['category_id', ''],
- ['security_code', ''],
- ['wx_url', '']
- ]);
- $securityCodeRecordServices->save((int)$id, $data);
- return app('json')->success($id ? 100001 : 100021);
- }
- /**
- * 删除
- * @param $id
- * @throws \Exception
- */
- public function delete()
- {
- list($id) = $this->request->getMore([
- ['id', 0],
- ], true);
- if (!$id) return app('json')->fail(100100);
- $this->services->delCode((int)$id);
- return app('json')->success(100002);
- }
- /**
- * 导入
- * @return \think\Response|void
- * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
- */
- public function import()
- {
- [$file] = $this->request->getMore([
- ['file', '']
- ], true);
- if (!$file) return app('json')->fail(400168);
- $file = public_path() . substr($file, 1);
- $expressData = app()->make(FileService::class)->readExcel($file, 'securityCode', 2);
- foreach ($expressData as $item) {
- $this->services->save(0, $item);
- }
- return app('json')->success('批量发货成功');
- }
- }
|