Template.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\printer\shop\controller;
  11. use app\shop\controller\BaseShop;
  12. use addon\printer\model\PrinterTemplate;
  13. class Template extends BaseShop
  14. {
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. $this->forthMenu();
  19. }
  20. /*
  21. * 模板管理列表
  22. */
  23. public function lists()
  24. {
  25. $model = new PrinterTemplate();
  26. if (request()->isAjax()) {
  27. $condition[] = [ 'site_id', '=', $this->site_id ];
  28. $page = input('page', 1);
  29. $page_size = input('page_size', PAGE_LIST_ROWS);
  30. $list = $model->getPrinterTemplatePageList($condition, $page, $page_size, 'template_id desc');
  31. return $list;
  32. }
  33. return $this->fetch("template/lists");
  34. }
  35. /**
  36. * 添加模板管理
  37. */
  38. public function add()
  39. {
  40. $model = new PrinterTemplate();
  41. $type = input('type', 'goodsorder');
  42. if (request()->isAjax()) {
  43. $data = [
  44. 'site_id' => $this->site_id,
  45. 'site_name' => $this->shop_info[ 'site_name' ],
  46. 'template_type' => input('template_type', ''),
  47. 'template_name' => input('template_name', ''),
  48. 'title' => input('title', ''),
  49. 'head' => input('head', ''),
  50. 'buy_notes' => input('buy_notes', ''),
  51. 'seller_notes' => input('seller_notes', ''),
  52. 'buy_name' => input('buy_name', ''),
  53. 'buy_mobile' => input('buy_mobile', ''),
  54. 'buy_address' => input('buy_address', ''),
  55. 'shop_mobile' => input('shop_mobile', ''),
  56. 'shop_address' => input('shop_address', ''),
  57. 'shop_qrcode' => input('shop_qrcode', ''),
  58. 'qrcode_url' => input('qrcode_url', ''),
  59. 'bottom' => input('bottom', ''),
  60. 'type' => input('type', ''),
  61. 'type_name' => input('type_name', ''),
  62. 'goods_price_show' => input('goods_price_show', 0),
  63. 'goods_code_show' => input('goods_code_show', 0),
  64. 'form_show' => input('form_show', 0),
  65. 'goods_price_type' => input('goods_price_type', ''),
  66. ];
  67. return $model->addPrinterTemplate($data);
  68. } else {
  69. $this->assign('template_type', $model->getTemplateType());
  70. $this->assign('type', $type);
  71. return event('PrinterTemplate', [ 'type' => $type, 'action' => 'add' ], true);
  72. }
  73. }
  74. /**
  75. * 编辑模板管理
  76. */
  77. public function edit()
  78. {
  79. $model = new PrinterTemplate();
  80. $template_id = input('template_id', 0);
  81. if (request()->isAjax()) {
  82. $data = [
  83. 'template_id' => $template_id,
  84. 'site_id' => $this->site_id,
  85. 'template_type' => input('template_type', ''),
  86. 'template_name' => input('template_name', ''),
  87. 'title' => input('title', ''),
  88. 'head' => input('head', ''),
  89. 'buy_notes' => input('buy_notes', ''),
  90. 'seller_notes' => input('seller_notes', ''),
  91. 'buy_name' => input('buy_name', ''),
  92. 'buy_mobile' => input('buy_mobile', ''),
  93. 'buy_address' => input('buy_address', ''),
  94. 'shop_mobile' => input('shop_mobile', ''),
  95. 'shop_address' => input('shop_address', ''),
  96. 'shop_qrcode' => input('shop_qrcode', ''),
  97. 'qrcode_url' => input('qrcode_url', ''),
  98. 'bottom' => input('bottom', ''),
  99. 'goods_price_show' => input('goods_price_show', 0),
  100. 'goods_code_show' => input('goods_code_show', 0),
  101. 'form_show' => input('form_show', 0),
  102. 'goods_price_type' => input('goods_price_type', ''),
  103. ];
  104. return $model->editPrinterTemplate($data);
  105. } else {
  106. $info = $model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ], [ 'site_id', '=', $this->site_id ] ]);
  107. $this->assign('info', $info[ 'data' ]);
  108. return event('PrinterTemplate', [ 'type' => $info[ 'data' ][ 'type' ], 'action' => 'edit' ], true);
  109. }
  110. }
  111. /*
  112. * 删除
  113. */
  114. public function delete()
  115. {
  116. $template_id = input('template_id', '');
  117. $printer_model = new PrinterTemplate();
  118. return $printer_model->deletePrinterTemplate([ [ 'template_id', '=', $template_id ], [ 'site_id', '=', $this->site_id ] ]);
  119. }
  120. }