OrderConveyPay.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\Db;
  5. use think\Exception;
  6. class OrderConveyPay extends Auth {
  7. public function index() {
  8. if (request()->isAjax()) {
  9. //分页参数
  10. $length = input('rows', 10, 'intval'); //每页条数
  11. $page = input('page', 1, 'intval'); //第几页
  12. $start = ($page - 1) * $length; //分页开始位置
  13. //排序
  14. $sortRow = input('sidx', 'id', 'trim'); //排序列
  15. $sort = input('sord', 'desc', 'trim'); //排序方式
  16. $order = $sortRow . ' ' . $sort;
  17. $map[] = ['org_id', '=', $this->orgId];
  18. $title = input('sn','','trim');
  19. if($title){
  20. $map[] = ['sn','like','%'.$title.'%'];
  21. }
  22. $enable = input('type','','trim');
  23. if($enable != ''){
  24. $map[] = ['type','=',$enable];
  25. }
  26. $enable = input('status','','trim');
  27. if($enable != ''){
  28. $map[] = ['status','=',$enable];
  29. }
  30. $map = empty($map) ? true : $map;
  31. //数据查询
  32. $lists = Db::name('order_convey_pay')
  33. ->where($map)
  34. ->limit($start, $length)
  35. ->order($order)
  36. ->select();
  37. //数据返回
  38. $totalCount = Db::name('order_convey_pay')->where($map)->count();
  39. $totalPage = ceil($totalCount / $length);
  40. $result['page'] = $page;
  41. $result['total'] = $totalPage;
  42. $result['records'] = $totalCount;
  43. $result['rows'] = $lists;
  44. return json($result);
  45. } else {
  46. return $this->fetch();
  47. }
  48. }
  49. public function pay($id=0){
  50. if(request()->isPost()){
  51. $remark = input('remark','','trim');
  52. $info = Db::name('order_convey_pay')->where('id',$id)->find();
  53. if(!$info){
  54. $this->error('订单不存在');
  55. }
  56. if($info['status'] == 1){
  57. $this->error('订单已支付');
  58. }
  59. $res = Db::name('order_convey_pay')->where('id',$id)->update([
  60. 'type' => 1,
  61. 'status' => 1,
  62. 'remark' => $remark,
  63. 'pay_time' => date('Y-m-d H:i:s')
  64. ]);
  65. if($res){
  66. $this->success('操作成功',url('index'));
  67. }else{
  68. $this->error('操作失败');
  69. }
  70. }else{
  71. if($id){
  72. $info = Db::name('order_convey_pay')->where('id',$id)->find();
  73. $this->assign('info',$info);
  74. }
  75. return $this->fetch();
  76. }
  77. }
  78. }