| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?php
- /**
- * @package merchant
- *
- * @author Qinii
- * @day 2020-06-15
- *
- *
- */
- namespace app\controller\admin\order;
- use crmeb\basic\BaseController;
- use app\common\repositories\store\ExcelRepository;
- use app\common\repositories\system\merchant\MerchantRepository;
- use app\common\repositories\store\order\StoreOrderRepository as repository;
- use think\App;
- use think\facade\Db;
- class Order extends BaseController
- {
- protected $repository;
- public function __construct(App $app, repository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- public function lst($id)
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['date','order_sn','order_type','keywords','username']);
- $where['reconciliation_type'] = $this->request->param('status', 1);
- $where['mer_id'] = $id;
- return app('json')->success($this->repository->adminGetList($where, $page, $limit));
- }
- public function markForm($id)
- {
- if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->adminMarkForm($id)));
- }
- public function mark($id)
- {
- if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
- return app('json')->fail('数据不存在');
- $data = $this->request->params(['admin_mark']);
- $this->repository->update($id, $data);
- return app('json')->success('备注成功');
- }
- /**
- * TODO
- * @return mixed
- * @author Qinii
- * @day 2020-06-25
- */
- public function getAllList()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','order_ids','paid']);
- $pay_type=$this->request->param('pay_type');
- if($pay_type==1 || $pay_type==4){
- $where['pay_type']=$pay_type;
- }
- if($pay_type==6){
- //一壶茶红积分兑换的
- $where['mer_id']=496;
- $where['pay_type']=5;
- }
- return app('json')->success($this->repository->merchantGetList($where, $page, $limit));
- }
- /**
- * TODO 自提订单列表
- * @return mixed
- * @author Qinii
- * @day 2020-08-17
- */
- public function getTakeList()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['date','order_sn','keywords','username']);
- $where['take_order'] = 1;
- $where['status'] = -1;
- $where['verify_date'] = $where['date'];
- unset($where['date']);
- return app('json')->success($this->repository->merchantGetList($where, $page, $limit));
- }
- /**
- * TODO
- * @return mixed
- * @author Qinii
- * @day 2020-08-17
- */
- public function chart()
- {
- $where = $this->request->params(['type', 'date', 'mer_id','keywords','username','order_sn','order_ids','paid']);
- return app('json')->success($this->repository->adminOrderNumber(-1, $where));
- }
- /**
- * TODO 自提订单头部统计
- * @return mixed
- * @author Qinii
- * @day 2020-08-17
- */
- public function takeChart()
- {
- return app('json')->success($this->repository->adminOrderNumber(1));
- }
- /**
- * TODO 订单类型
- * @return mixed
- * @author Qinii
- * @day 2020-08-15
- */
- public function orderType()
- {
- return app('json')->success($this->repository->orderType([]));
- }
- public function detail($id)
- {
- $data = $this->repository->getOne($id, null);
- if (!$data)
- return app('json')->fail('数据不存在');
- return app('json')->success($data);
- }
- /**
- * TODO 快递查询
- * @param $id
- * @return mixed
- * @author Qinii
- * @day 2020-06-25
- */
- public function express($id)
- {
- if (!$this->repository->getWhereCount(['order_id' => $id, 'delivery_type' => 1]))
- return app('json')->fail('订单信息或状态错误');
- return app('json')->success($this->repository->express($id));
- }
- public function reList($id)
- {
- [$page, $limit] = $this->getPage();
- $where = ['reconciliation_id' => $id, 'type' => 0];
- return app('json')->success($this->repository->reconList($where, $page, $limit));
- }
- /**
- * TODO 导出文件
- * @author Qinii
- * @day 2020-07-30
- */
- public function excel()
- {
- $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn']);
- app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'order',0);
- return app('json')->success('开始导出数据');
- }
- /**
- * 养老金打款凭证 列表
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function order_red_list()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['status', 'date']);
- // $where['mer_id'] = $this->request->merId();
- $query = Db::name('enterprise_red_order_voucher')->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
- getModelTime($query, $where['date']);
- })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
- $query->where('status',$where['status']);
- });
- $data['count'] = $query->count();
- $data['list'] = $query->page($page, $limit)->order('id desc')->select();
- return app('json')->success('ok', $data);
- }
- /**
- * 养老金提交打款凭证 审核
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function order_red_status()
- {
- $post= $this->request->params(['id', 'status', 'refund_message']);
- $voucher=Db::name('enterprise_red_order_voucher')->find($post['id']);
- if(!$voucher){
- return app('json')->fail('订单信息错误');
- }
- if($voucher['status']!=0){
- return app('json')->fail('请勿重复操作');
- }
- if($post['status']==2){
- $update['status']=2;
- $update['refund_message']=$post['refund_message'];
- if($post['refund_message']==''){
- return app('json')->fail('请输入不通过原因');
- }
- $is_red_ylj=0;
- }else{
- $update['status']=1;
- $is_red_ylj=2;
- }
- $update['status_time']=date('Y-m-d H:i:s');
- $re=Db::name('enterprise_red_order_voucher')->where('id',$post['id'])->update($update);
- Db::name('store_order')->whereIn('order_id',$voucher['order_ids'])->where('is_red_ylj',1)->update(['is_red_ylj'=>$is_red_ylj]);
- $where['o.paid'] = 1;
- // $where['o.pay_type'] = 5;
- $where['u.commission_type'] = 5;
- $where['u.gzc'] = 3;
- $where['u.status'] = 0;
- $bill_id = Db::name('store_order')
- ->alias('o')
- ->join('user_bill u', 'u.order_sn=o.order_sn')
- ->where($where)
- ->whereIN('o.pay_type',[0,5])
- ->whereIn('o.order_id', $voucher['order_ids'])
- ->column('u.bill_id');
- Db::name('user_bill')->whereIn('bill_id',$bill_id)->update(['status'=>1,'gzc'=>0]);
- if($re){
- return app('json')->success('操作成功');
- }
- return app('json')->fail('操作失败');
- }
- }
|