123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- <?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\export;
- use app\adminapi\controller\AuthController;
- use app\services\activity\bargain\StoreBargainServices;
- use app\services\activity\combination\StoreCombinationServices;
- use app\services\activity\combination\StorePinkServices;
- use app\services\activity\seckill\StoreSeckillServices;
- use app\services\agent\AgentManageServices;
- use app\services\other\export\ExportServices;
- use app\services\order\StoreOrderServices;
- use app\services\product\product\StoreProductServices;
- use app\services\system\store\SystemStoreServices;
- use app\services\user\member\MemberCardServices;
- use app\services\user\member\SecurityCodeRecordServices;
- use app\services\user\UserBillServices;
- use app\services\user\UserRechargeServices;
- use app\services\wechat\WechatUserServices;
- use think\facade\App;
- /**
- * 导出excel类
- * Class ExportExcel
- * @package app\adminapi\controller\v1\export
- */
- class ExportExcel extends AuthController
- {
- /**
- * @var ExportServices
- */
- protected $service;
- /**
- * ExportExcel constructor.
- * @param App $app
- * @param ExportServices $services
- */
- public function __construct(App $app, ExportServices $services)
- {
- parent::__construct($app);
- $this->service = $services;
- }
- public function userList()
- {
- $where = $this->request->getMore([
- ['page', 1],
- ['limit', 20],
- ['nickname', ''],
- ['status', ''],
- ['pay_count', ''],
- ['is_promoter', ''],
- ['order', ''],
- ['data', ''],
- ['user_type', ''],
- ['country', ''],
- ['province', ''],
- ['city', ''],
- ['city_name', ''],
- ['user_time_type', ''],
- ['user_time', ''],
- ['sex', ''],
- [['level', 0], 0],
- [['group_id', 'd'], 0],
- ['label_id', ''],
- ['now_money', 'normal'],
- ['field_key', ''],
- ['isMember', ''],
- ['ids', []]
- ]);
- return app('json')->success($this->service->exportUserList($where));
- }
- /**
- * 订单导出
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function orderList()
- {
- $where = $this->request->getMore([
- ['status', ''],
- ['real_name', ''],
- ['is_del', ''],
- ['data', '', '', 'time'],
- ['type', ''],
- ['pay_type', ''],
- ['order', ''],
- ['field_key', ''],
- ['ids', []],
- ]);
- $where['is_system_del'] = 0;
- $where['pid'] = 0;
- return app('json')->success($this->service->exportOrderList($where));
- }
- /**
- * 防伪码导出
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function codeList()
- {
- $where = $this->request->getMore([
- ['category_id', ""],
- ['security_code', ""],
- ['scan_uid', ""],
- ['status', ""]
- ]);
- return app('json')->success($this->service->exportCodeList($where));
- }
- /**
- * 发货订单列表导出
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function orderDeliveryList()
- {
- return app('json')->success($this->service->exportOrderDeliveryList());
- }
- /**
- * 商品列表导出
- * @return mixed
- */
- public function productList()
- {
- $where = $this->request->getMore([
- ['store_name', ''],
- ['cate_id', ''],
- ['type', 1],
- ['ids', []]
- ]);
- return app('json')->success($this->service->exportProductList($where));
- }
- /**
- * 砍价商品列表导出
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function bargainList()
- {
- $where = $this->request->getMore([
- ['status', ''],
- ['store_name', ''],
- ]);
- $where['is_del'] = 0;
- return app('json')->success($this->service->exportBargainList($where));
- }
- /**
- * 拼团商品导出
- * @return mixed
- */
- public function combinationList()
- {
- $where = $this->request->getMore([
- ['is_show', ''],
- ['store_name', '']
- ]);
- $where['is_del'] = 0;
- return app('json')->success($this->service->exportCombinationList($where));
- }
- /**
- * 秒杀商品导出
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function seckillList()
- {
- $where = $this->request->getMore([
- [['status', 's'], ''],
- [['store_name', 's'], '']
- ]);
- return app('json')->success($this->service->exportSeckillList($where));
- }
- /**
- * 会员卡导出
- * @param $id
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function memberCardList($id)
- {
- return app('json')->success($this->service->exportMemberCard($id));
- }
- /**
- * 保存用户资金监控的excel表格
- * @param UserBillServices $services
- * @return mixed
- */
- public function userFinance(UserBillServices $services)
- {
- $where = $this->request->getMore([
- ['start_time', ''],
- ['end_time', ''],
- ['nickname', ''],
- ['type', ''],
- ]);
- $data = $services->getBillList($where, '*', false);
- return app('json')->success($this->service->userFinance($data['data'] ?? []));
- }
- /**
- * 用户佣金
- * @param UserBillServices $services
- * @return mixed
- */
- public function userCommission(UserBillServices $services)
- {
- $where = $this->request->getMore([
- ['page', 1],
- ['limit', 20],
- ['nickname', ''],
- ['price_max', ''],
- ['price_min', ''],
- ['excel', '1'],
- ['time', ''],
- ]);
- $data = $services->getCommissionList($where, false);
- return app('json')->success($this->service->userCommission($data['list'] ?? []));
- }
- /**
- * 用户积分
- * @param UserBillServices $services
- * @return mixed
- */
- public function userPoint(UserBillServices $services)
- {
- $where = $this->request->getMore([
- ['start_time', ''],
- ['end_time', ''],
- ['nickname', ''],
- ['excel', '1'],
- ]);
- $data = $services->getPointList($where, '*', false);
- return app('json')->success($this->service->userPoint($data['list'] ?? []));
- }
- /**
- * 用户充值
- * @param UserRechargeServices $services
- * @return mixed
- */
- public function userRecharge(UserRechargeServices $services)
- {
- $where = $this->request->getMore([
- ['data', ''],
- ['paid', ''],
- ['page', 1],
- ['limit', 20],
- ['nickname', ''],
- ['excel', '1'],
- ]);
- $data = $services->getRechargeList($where, '*', false);
- return app('json')->success($this->service->userRecharge($data['list'] ?? []));
- }
- /**
- * 分销管理 用户推广
- * @param AgentManageServices $services
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function userAgent(AgentManageServices $services)
- {
- $where = $this->request->getMore([
- ['nickname', ''],
- ['data', ''],
- ['excel', '1'],
- ]);
- $data = $services->agentSystemPage($where, false);
- return app('json')->success($this->service->userAgent($data['list']));
- }
- /**
- * 微信用户导出(弃用)
- * @param WechatUserServices $services
- * @return mixed
- */
- public function wechatUser(WechatUserServices $services)
- {
- $where = $this->request->getMore([
- ['page', 1],
- ['limit', 20],
- ['nickname', ''],
- ['data', ''],
- ['tagid_list', ''],
- ['groupid', '-1'],
- ['sex', ''],
- ['export', '1'],
- ['subscribe', '']
- ]);
- $tagidList = explode(',', $where['tagid_list']);
- foreach ($tagidList as $k => $v) {
- if (!$v) {
- unset($tagidList[$k]);
- }
- }
- $tagidList = array_unique($tagidList);
- $where['tagid_list'] = implode(',', $tagidList);
- $data = $services->exportData($where);
- return app('json')->success($this->service->wechatUser($data));
- }
- /**
- * 商铺砍价活动导出
- * @param StoreBargainServices $services
- * @return mixed
- */
- public function storeBargain(StoreBargainServices $services)
- {
- $where = $this->request->getMore([
- ['start_status', ''],
- ['status', ''],
- ['store_name', ''],
- ]);
- $data = $services->getList($where);
- return app('json')->success($this->service->storeBargain($data));
- }
- /**
- * 拼团导出
- * @param StoreCombinationServices $services
- * @return mixed
- */
- public function storeCombination(StoreCombinationServices $services)
- {
- $where = $this->request->getMore([
- ['start_status', ''],
- ['is_show', ''],
- ['store_name', ''],
- ]);
- $data = $services->getList($where);
- /** @var StorePinkServices $storePinkServices */
- $storePinkServices = app()->make(StorePinkServices::class);
- $countAll = $storePinkServices->getPinkCount([]);
- $countTeam = $storePinkServices->getPinkCount(['k_id' => 0, 'status' => 2]);
- $countPeople = $storePinkServices->getPinkCount(['k_id' => 0]);
- foreach ($data as &$item) {
- $item['count_people'] = $countPeople[$item['id']] ?? 0;//拼团数量
- $item['count_people_all'] = $countAll[$item['id']] ?? 0;//参与人数
- $item['count_people_pink'] = $countTeam[$item['id']] ?? 0;//成团数量
- $item['stop_status'] = $item['stop_time'] < time() ? 1 : 0;
- if ($item['is_show']) {
- if ($item['start_time'] > time())
- $item['start_name'] = '未开始';
- else if ($item['stop_time'] < time())
- $item['start_name'] = '已结束';
- else if ($item['stop_time'] > time() && $item['start_time'] < time()) {
- $item['start_name'] = '进行中';
- }
- } else $item['start_name'] = '已结束';
- }
- return app('json')->success($this->service->storeCombination($data));
- }
- /**
- * 秒杀导出
- * @param StoreSeckillServices $services
- * @return mixed
- */
- public function storeSeckill(StoreSeckillServices $services)
- {
- $where = $this->request->getMore([
- ['start_status', ''],
- ['status', ''],
- ['store_name', '']
- ]);
- $data = $services->getList($where);
- return app('json')->success($this->service->storeSeckill($data));
- }
- /**
- * 商品导出
- * @param StoreProductServices $services
- * @return mixed
- */
- public function storeProduct(StoreProductServices $services)
- {
- $where = $this->request->getMore([
- ['store_name', ''],
- ['cate_id', ''],
- ['type', 1]
- ]);
- $data = $services->searchList($where, true, false);
- return app('json')->success($this->service->storeProduct($data['list'] ?? []));
- }
- /**
- * 订单列表导出
- * @param StoreOrderServices $services
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function storeOrder(StoreOrderServices $services)
- {
- $where = $this->request->getMore([
- ['status', ''],
- ['real_name', ''],
- ['data', '', '', 'time']
- ]);
- $where['pid'] = 0;
- $ids = $this->request->get('ids');
- if ($ids) {
- $idsArr = array_filter(explode(',', $ids));
- if ($idsArr) {
- $where['id'] = $idsArr;
- }
- }
- $data = $services->getExportList($where);
- return app('json')->success($this->service->storeOrder($data));
- }
- /**
- * 获取提货点
- * @param SystemStoreServices $services
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function storeMerchant(SystemStoreServices $services)
- {
- $where = $this->request->getMore([
- [['keywords', 's'], ''],
- [['type', 'd'], 0],
- ]);
- $data = $services->getExportData($where);
- return app('json')->success($this->service->storeMerchant($data));
- }
- /**
- * 会员卡导出
- * @param int $id
- * @param MemberCardServices $services
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function memberCard(int $id, MemberCardServices $services)
- {
- $data = $services->getExportData(['batch_card_id' => $id]);
- return app('json')->success($this->service->memberCard($data));
- }
- }
|