| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace app\admin\controller\service\card;
- use app\common\controller\Backend;
- use think\Db;
- /**
- * 套餐卡订单
- *
- * @icon fa fa-circle-o
- */
- class Refund extends Backend
- {
- /**
- * Refund模型对象
- * @var \app\admin\model\service\card\Refund
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\service\card\Refund;
- $this->view->assign("paytypeList", $this->model->getPaytypeList());
- $this->view->assign("isServiceList", $this->model->getIsServiceList());
- $this->view->assign("statusList", $this->model->getStatusList());
- }
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if (false === $this->request->isAjax()) {
- return $this->view->fetch();
- }
- //如果发送的来源是 Selectpage,则转发到 Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- [$where, $sort, $order, $offset, $limit] = $this->buildparams();
- $list = $this->model
- ->where($where)
- ->where('is_service','in','1,2,-1')
- ->order($sort, $order)
- ->paginate($limit);
- if($list)
- {
- foreach ($list as &$value)
- {
- $value->nickname = \app\admin\model\User::where(['id'=>$value->user_id])->value('nickname');
- }
- }
- $result = ['total' => $list->total(), 'rows' => $list->items()];
- return json($result);
- }
- public function agree($ids = null)
- {
- $row = $this->model->get($ids);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- $row->is_service != 1 && $this->error('请勿重复审核');
- $row->status != -2 && $this->error('套餐卡状态异常');
- Db::startTrans();
- try{
- \app\api\model\service\User::money(+$row->refund_price,$row->user_id,'套餐卡订单取消退款');
- $row->allowField(true)->save(['is_service'=>2,'status'=>-3,'updatetime'=>time()]);
- Db::commit();
- } catch (Exception $e) {
- Db::rollback();
- $this->error('退款通过失败',$e->getMessage());
- }
- $this->success('退款已通过');
- }
- public function refuse($ids = null)
- {
- $row = $this->model->get($ids);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- $row->is_service != 1 && $this->error('请勿重复审核');
- $row->status != -2 && $this->error('套餐卡状态异常');
- if($this->request->isPost()){
- $params = $this->request->post('row/a');
- Db::startTrans();
- try{
- $row->allowField(true)->save(['status'=>$row->original_status,'is_service'=>-1,'updatetime'=>time(),'note'=>$params['note']]);
- Db::commit();
- } catch (Exception $e) {
- Db::rollback();
- $this->error('退款拒绝失败',$e->getMessage());
- }
- $this->success('退款已拒绝');
- }
- $this->view->assign("id", $ids);
- return $this->view->fetch();
- }
- }
|