Invoice.php 2.4 KB

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