PrinterTemplate.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\printer\model;
  11. use app\model\BaseModel;
  12. class PrinterTemplate extends BaseModel
  13. {
  14. public $type = [
  15. 'goodsorder' => [
  16. 'type' => 'goodsorder',
  17. 'type_name' => '商品订单',
  18. 'edit' => 'addon/printer/shop/view/template/goodsorder_template.html',
  19. 'add' => 'addon/printer/shop/view/template/goodsorder_template.html',
  20. ]
  21. ];
  22. public function getTemplateType()
  23. {
  24. $type = $this->type;
  25. $other_type = event('PrinterTemplateType', []);
  26. foreach ($other_type as $k => $v) {
  27. foreach ($v as $val) {
  28. $type[ $val[ 'type' ] ] = $val;
  29. }
  30. }
  31. return $type;
  32. }
  33. /**
  34. * 添加打印模板
  35. * @param $data
  36. * @return array
  37. */
  38. public function addPrinterTemplate($data)
  39. {
  40. $data[ 'create_time' ] = time();
  41. $res = model('printer_template')->add($data);
  42. return $this->success($res);
  43. }
  44. /**
  45. * 编辑打印模板
  46. * @param $data
  47. * @return array
  48. */
  49. public function editPrinterTemplate($data)
  50. {
  51. $data[ 'update_time' ] = time();
  52. $res = model('printer_template')->update($data, [ [ 'template_id', '=', $data[ 'template_id' ] ] ]);
  53. return $this->success($res);
  54. }
  55. /**
  56. * 删除
  57. * @param $condition
  58. * @return array
  59. */
  60. public function deletePrinterTemplate($condition)
  61. {
  62. $res = model('printer_template')->delete($condition);
  63. return $this->success($res);
  64. }
  65. /**
  66. * 获取打印模板信息
  67. * @param array $condition
  68. * @param string $field
  69. * @return array
  70. */
  71. public function getPrinterTemplateInfo($condition = [], $field = '*')
  72. {
  73. $res = model('printer_template')->getInfo($condition, $field);
  74. return $this->success($res);
  75. }
  76. /**
  77. * 获取打印模板列表
  78. * @param array $condition
  79. * @param string $field
  80. * @param string $order
  81. * @param string $limit
  82. */
  83. public function getPrinterTemplateList($condition = [], $field = '*', $order = '', $limit = null)
  84. {
  85. $list = model('printer_template')->getList($condition, $field, $order, '', '', '', $limit);
  86. return $this->success($list);
  87. }
  88. /**
  89. * 获取打印模板分页列表
  90. * @param array $condition
  91. * @param number $page
  92. * @param string $page_size
  93. * @param string $order
  94. * @param string $field
  95. */
  96. public function getPrinterTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
  97. {
  98. $list = model('printer_template')->pageList($condition, $field, $order, $page, $page_size);
  99. return $this->success($list);
  100. }
  101. }