Exemplo n.º 1
0
 public function repay_normal($order_id = 0, $issue = 0)
 {
     $uid = $this->_user['uid'];
     $orderModel = new OrderModel();
     $order = $orderModel->where(['uid' => $uid, 'id' => $order_id])->find() or $this->error('找不到订单信息!');
     $bill = M('loan_bill')->where(['order_id' => $order_id, 'issue' => $issue])->find() or $this->error('找不到此账单!');
     if (IS_POST) {
         $this->redirect("/pay/alipay/order_id/{$order_id}/issue/{$issue}");
     }
     $this->assign('order', $order);
     $this->assign('bill', $bill);
     $this->display();
 }
Exemplo n.º 2
0
 public function lists()
 {
     $orderModel = new OrderModel();
     $config = $this->_getWhere(I('cate', 'my'));
     $where = $config['where'];
     $type = I('type', 0, 'intval');
     if ($type) {
         $where['o.type'] = $type;
     }
     // 搜索
     $search = I('search');
     if ($search) {
         $where += ['o.id|o.realname' => $search];
     }
     $page_size = 30;
     $limit = I('limit', 0, 'intval');
     $model = M()->table('zj_loan_order o')->join('zj_university_campus c on c.id=o.campus_id', 'left');
     isset($where['f.payee_name']) and $model->join('zj_loan_order_finance f on f.order_id=o.id');
     $model->field('o.id,o.type,o.created,o.title,o.realname,c.university_name,c.name campus_name');
     $list = $model->where($where)->order('o.id desc')->limit($limit, $page_size)->select();
     $type = $orderModel->getType();
     foreach ($list as $key => $vo) {
         $list[$key]['type'] = mb_substr($type[$vo['type']], 0, 2);
     }
     ajax_success($list);
 }
 /**
  * @title 获取订单统计
  *
  * @param string $company_id 商铺编号
  *       
  * @method get
  */
 public function order_stat($company_id)
 {
     $uid = $this->_user['uid'];
     M('loan_company')->where(['id' => $company_id, 'uid' => $uid])->count() or ajax_error('无权访问此商铺!');
     $orderModel = new \Loan\Model\OrderModel();
     $where = ['company_id' => $company_id, 'status' => ['neq', $orderModel::STATUS_CLOSED]];
     ajax_success(['statistiscs' => [['label' => '订单统计', 'content' => [['text' => '进行中的订单', 'value' => $orderModel->where($where + ['check_status' => ['neq', 1]])->count() + 0 . ''], ['text' => '已签约订单', 'value' => $orderModel->where($where + ['check_status' => 1])->count() + 0 . '']]], ['label' => '签约订单贷款金额统计', 'content' => [['text' => '待付款金额(元)', 'value' => number_format($orderModel->where($where + ['check_status' => 1, 'lend_status' => ['neq', 2]])->sum('loan_money'), 2)], ['text' => '已付款金额(元)', 'value' => number_format($orderModel->where($where + ['check_status' => 1, 'lend_status' => 2])->sum('loan_money'), 2)]]]]]);
 }
 /**
  * @title 获取订单详情
  *
  * @param string $id 订单编号 108323 测试环境,不对订单所属进行验证
  *       
  * @method get
  */
 public function order_detail($id)
 {
     $orderModel = new OrderModel();
     $uid = $this->_user['uid'];
     $field = 'id,uid,created,type,status,title,goods_pic pic,realname,mobile,money,first_money,month,month_total,remark,failure_reason';
     $where = ['id' => $id, 'company_id' => ['exp', ' in (select id from zj_loan_company where uid=' . $uid . ')']];
     $order = $orderModel->where($where)->field($field)->find() or ajax_error('找不到此订单信息!');
     $order_id = $order['id'];
     $type_config = $orderModel->getType();
     $status_config = $orderModel->getStatus();
     $order['type_text'] = isset($type_config[$order['type']]) ? $type_config[$order['type']] : '未知:' . $order['type'];
     $order['status_text'] = isset($status_config[$order['status']]) ? $status_config[$order['status']] : '未知:' . $order['status'];
     // 自定义显示文字
     $item_texts = [['label' => '创建日期', 'text' => date('Y-m-d H:i', $order['created']), 'color' => '#666'], ['label' => '状态', 'text' => $order['status_text'], 'color' => '#666'], ['label' => '类型', 'text' => $order['type_text']], ['label' => '姓名', 'text' => $order['realname']], ['label' => '联系电话', 'text' => $order['mobile']], ['label' => '价格', 'text' => $order['money']], ['label' => '首付', 'text' => $order['first_money']], ['label' => '分期数', 'text' => $order['month']], ['label' => '月供', 'text' => $order['month_total']], ['label' => '客户备注', 'text' => $order['remark']], ['label' => 'divider'], ['label' => '业务员', 'text' => M()->table('zj_loan_order_salesman s')->join('zj_user u on u.uid=s.uid')->where('s.order_id=' . $order['id'])->getField('u.realname') ?: '-']];
     if ($order['status'] == $orderModel::STATUS_CHECK_FAILURE) {
         $item_texts[] = ['label' => '签约失败', 'text' => $order['failure_reason'] ?: '-'];
     }
     if ($order['status'] == $orderModel::STATUS_CLOSED) {
         $item_texts[] = ['label' => '关闭原因', 'text' => $order['failure_reason'] ?: '-'];
     }
     // 自定义操作
     $where = ['uid' => $order['uid']];
     $contract_status = M('loan_user_contract')->where($where)->getField('status');
     if ($contract_status === null) {
         $user_auth_text = '未提交资料';
     } elseif ($contract_status == 0) {
         // 检查提交资料是否完善
         $user_auth = M('loan_user_contract_auth')->where($where)->getField('auth_id', true);
         if ($user_auth) {
             $auth_config = M('loan_config_auth')->where('type=1 and status=1 and is_required=1')->getField('id', true);
             foreach ($auth_config as $key => $id) {
                 if (in_array($id, $user_auth)) {
                     unset($auth_config[$key]);
                 }
             }
             if ($auth_config) {
                 $user_auth_text = '待完善资料';
             } else {
                 $user_auth_text = '等待审核';
             }
         } else {
             $user_auth_text = '未提交资料';
         }
     } elseif ($contract_status == 1) {
         $user_auth_text = '审核已通过';
     } elseif ($contract_status == 2) {
         $user_auth_text = '审核不通过';
     }
     $item_pages = [['name' => 'auth_user', 'text' => $user_auth_text, 'color' => '#333333']];
     // 自定义按钮
     $btns = [];
     // 输出结果
     ajax_success(['order' => $order, 'item_text' => $item_texts, 'item_page' => $item_pages, 'btns' => $btns]);
 }
Exemplo n.º 5
0
 public function order($type = '', $id = '')
 {
     $model = new \Loan\Model\OrderModel();
     $uid = $this->user['uid'];
     if ($type == 'detail') {
         $order = $model->where(['uid' => $uid, 'id' => $id])->find() or $this->error('找不到此订单信息!');
         // 读取快递信息
         $delivery = M('loan_order_delivery')->where(['order_id' => $order['id']])->find();
         // 读取日志信息
         $log = M('loan_order_log')->where(['order_id' => $order['id']])->order('id')->select();
         $this->assign('step', [OrderModel::STATUS_UNCONTRACT => 1, OrderModel::STATUS_UNCHECK => 2, OrderModel::STATUS_UNPAY => 2, OrderModel::STATUS_CHECK_SUCCESS => 3, OrderModel::STATUS_DELIVERY => 4, OrderModel::STATUS_REPAY => 5, OrderModel::STATUS_FINISH_SUCCESS => 5, OrderModel::STATUS_CLOSED => 0][$order['status']]);
         $this->assign('user', M('loan_user_contract')->find($uid));
         $this->assign('order', $order);
         $this->assign('orderModel', $model);
         $this->assign('delivery', $delivery);
         $this->assign('_log', $log);
         $this->display('order_detail');
         return;
     } elseif ($type == 'close') {
         $model->close($id, I('reason'));
         $this->redirect('/user/order');
     }
     $list = $model->order('id DESC')->where(['status' => ['neq', OrderModel::STATUS_CLOSED], 'uid' => $uid])->select();
     $order_status = $model->getStatus();
     foreach ($list as &$item) {
         $item['allow_close'] = $model->allowClose($item);
         $item['status_text'] = isset($order_status[$item['status']]) ? $order_status[$item['status']] : '';
     }
     $this->assign('list', $list);
     $this->assign('orderModel', $model);
     $this->display();
 }
Exemplo n.º 6
0
 public function apply()
 {
     $order = $this->_order();
     $model = new \Loan\Model\OrderModel();
     if ($order['status'] == $model::STATUS_CHECK_FAILURE) {
         $model->checkFailureApply($order['id']) or ajax_error($model->getError());
     } else {
         $salesModel = new \Loan\Model\OrderSalesmanModel();
         $history = $salesModel->where(['order_id' => $order['id']])->find();
         if ($history) {
             if ($history['uid'] != $this->_user['uid']) {
                 ajax_error('无权操作:此订单已指派给别人!');
             }
         } else {
             $salesModel->assign($order['id'], $this->_user['uid']) or ajax_error($salesModel->getError());
         }
         $salesModel->save(['order_id' => $order['id'], 'uid' => $this->_user['uid'], 'status' => 1]);
         // 更新审核次数
         M('loan_order_other')->where(['order_id' => $order['id']])->setInc('total_apply_check');
         D('SystemNotification')->addByType('order_wait_check', $order['id']);
     }
     ajax_success();
 }