{"size": 1865, "ext": "js", "max_stars_repo_path": "server/lib/order.js", "max_stars_repo_name": "keepFur/jinhuobao-admin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/lib/order.js", "max_issues_repo_name": "keepFur/jinhuobao-admin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/lib/order.js", "max_forks_repo_name": "keepFur/jinhuobao-admin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.6315789474, "max_line_length": 60, "alphanum_fraction": 0.4262734584}
const DB = require('../db/index')
class Order {
  createOrder (req, res) {
    DB.order.createOrder(req.body).then(() => {
      res.send({
        ret: 0,
        msg: ''
      })
    }).catch(err => {
      res.send({
        ret: 1,
        msg: err.message
      })
    })
  }

  readOrderList (req, res) {
    DB.order.readOrderList(req.query).then(resData => {
      DB.order.readOrderListTotal(req.query).then(total => {
        res.send({
          ret: 0,
          msg: '',
          total: total.total,
          rows: [{
            num: '123123123',
            star: 0,
            store: '之间',
            remark: '没事',
            arrivedDate: '2019-29-20',
            goods: [12, 12, 12],
            count: 10,
            status: 1,
            paymethod: 1,
            paySerialNum: '123123123123',
            totalPrice: 1000,
            discountPrice: 100,
            actualPrice: 900,
            runPrice: 0
          }] || resData
        })
      })
    }).catch(err => {
      res.send({
        ret: 1,
        msg: err.message
      })
    })
  }

  readOrderById (req, res) {
    DB.order.readOrderById(req.query).then(resData => {
      res.send({
        ret: 0,
        msg: '',
        order: resData
      })
    }).catch(err => {
      res.send({
        ret: 1,
        msg: err.message
      })
    })
  }

  updateOrderById (req, res) {
    DB.order.updateOrderById(req.body).then(() => {
      res.send({
        ret: 0,
        msg: ''
      })
    }).catch(err => {
      res.send({
        ret: 1,
        msg: err.message
      })
    })
  }

  deleteOrderById (req, res) {
    DB.order.deleteOrderById(req.body).then(() => {
      res.send({
        ret: 0,
        msg: ''
      })
    }).catch(err => {
      res.send({
        ret: 1,
        msg: err.message
      })
    })
  }
}

module.exports = new Order()
