Invoice.php 2.3 KB

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