Invoice.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Invoice extends BaseModel
  12. {
  13. /**
  14. * 取得买家默认发票
  15. * @access public
  16. * @author csdeshang
  17. * @param array $condition 条件数组
  18. * @return array
  19. */
  20. public function getDefaultInvoiceInfo($condition = array())
  21. {
  22. return Db::name('invoice')->where($condition)->order('invoice_state asc')->find();
  23. }
  24. /**
  25. * 取得单条发票信息
  26. * @access public
  27. * @author csdeshang
  28. * @param array $condition 查询条件
  29. */
  30. public function getInvoiceInfo($condition = array())
  31. {
  32. return Db::name('invoice')->where($condition)->find();
  33. }
  34. /**
  35. * 取得发票列表
  36. * @access public
  37. * @author csdeshang
  38. * @param type $condition 条件
  39. * @param type $limit 限制
  40. * @param type $field 字段
  41. * @return type
  42. */
  43. public function getInvoiceList($condition, $limit = 0, $field = '*')
  44. {
  45. return Db::name('invoice')->field($field)->where($condition)->limit($limit)->select()->toArray();
  46. }
  47. /**
  48. * 删除发票信息
  49. * @access public
  50. * @author csdeshang
  51. * @param array $condition 条件
  52. * @return bool
  53. */
  54. public function delInvoice($condition)
  55. {
  56. return Db::name('invoice')->where($condition)->delete();
  57. }
  58. /**
  59. * 新增发票信息
  60. * @access public
  61. * @author csdeshang
  62. * @param array $data 参数内容
  63. * @return bool
  64. */
  65. public function addInvoice($data)
  66. {
  67. return Db::name('invoice')->insertGetId($data);
  68. }
  69. /**
  70. * 编辑发票
  71. * @param type $data
  72. * @param type $condition
  73. * @return type
  74. */
  75. public function editInvoice($data, $condition)
  76. {
  77. return Db::name('invoice')->where($condition)->update($data);
  78. }
  79. }