PrinterController.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\controller\printer;
  20. use app\adminapi\controller\BaseAdminController;
  21. use app\adminapi\lists\printer\PrinterList;
  22. use app\adminapi\lists\printer\PrinterTemplateList;
  23. use app\adminapi\logic\printer\PrinterLogic;
  24. use app\adminapi\validate\printer\PrinterTemplateValidate;
  25. use app\adminapi\validate\printer\PrinterValidate;
  26. use app\common\service\JsonService;
  27. /**
  28. * 小票打印
  29. */
  30. class PrinterController extends BaseAdminController
  31. {
  32. /**
  33. * @notes 打印机列表
  34. * @return \think\response\Json
  35. * @author Tab
  36. * @date 2021/11/15 17:45
  37. */
  38. public function printerLists()
  39. {
  40. return JsonService::dataLists(new PrinterList());
  41. }
  42. /**
  43. * @notes 获取打印机类型
  44. * @return \think\response\Json
  45. * @author Tab
  46. * @date 2021/11/15 16:15
  47. */
  48. public function getPrinterType()
  49. {
  50. return JsonService::success('', PrinterLogic::getPrinterType(), 1, 0);
  51. }
  52. /**
  53. * @notes 添加打印机
  54. * @return \think\response\Json
  55. * @author Tab
  56. * @date 2021/11/15 17:14
  57. */
  58. public function addPrinter()
  59. {
  60. $params = (new PrinterValidate())->post()->goCheck('addPrinter');
  61. $result = PrinterLogic::addPrinter($params);
  62. if ($result) {
  63. return JsonService::success('添加成功', [], 1, 1);
  64. }
  65. return JsonService::fail(PrinterLogic::getError());
  66. }
  67. /**
  68. * @notes 获取打印机详情
  69. * @return \think\response\Json
  70. * @author Tab
  71. * @date 2021/11/16 11:48
  72. */
  73. public function printerDetail()
  74. {
  75. $params = (new PrinterValidate())->goCheck('printerDetail');
  76. $result = PrinterLogic::printerDetail($params);
  77. return JsonService::data($result);
  78. }
  79. /**
  80. * @notes 编辑打印机
  81. * @return \think\response\Json
  82. * @author Tab
  83. * @date 2021/11/15 17:24
  84. */
  85. public function editPrinter()
  86. {
  87. $params = (new PrinterValidate())->post()->goCheck('editPrinter');
  88. $result = PrinterLogic::editPrinter($params);
  89. if ($result) {
  90. return JsonService::success('编辑成功', [], 1, 1);
  91. }
  92. return JsonService::fail(PrinterLogic::getError());
  93. }
  94. /**
  95. * @notes 删除打印机
  96. * @return \think\response\Json
  97. * @author Tab
  98. * @date 2021/11/15 18:49
  99. */
  100. public function deletePrinter()
  101. {
  102. $params = (new PrinterValidate())->post()->goCheck('deletePrinter');
  103. $result = PrinterLogic::deletePrinter($params);
  104. if ($result) {
  105. return JsonService::success('删除成功', [], 1, 1);
  106. }
  107. return JsonService::fail(PrinterLogic::getError());
  108. }
  109. /**
  110. * @notes 添加模板
  111. * @return \think\response\Json
  112. * @author Tab
  113. * @date 2021/11/15 18:17
  114. */
  115. public function addTemplate()
  116. {
  117. $params = (new PrinterTemplateValidate())->post()->goCheck('addTemplate');
  118. $result = PrinterLogic::addTemplate($params);
  119. if ($result) {
  120. return JsonService::success('添加成功', [], 1, 1);
  121. }
  122. return JsonService::fail(PrinterLogic::getError());
  123. }
  124. /**
  125. * @notes 编辑模板
  126. * @return \think\response\Json
  127. * @author Tab
  128. * @date 2021/11/15 18:41
  129. */
  130. public function editTemplate()
  131. {
  132. $params = (new PrinterTemplateValidate())->post()->goCheck('editTemplate');
  133. $result = PrinterLogic::editTemplate($params);
  134. if ($result) {
  135. return JsonService::success('编辑成功', [], 1, 1);
  136. }
  137. return JsonService::fail(PrinterLogic::getError());
  138. }
  139. /**
  140. * @notes 删除模板
  141. * @return \think\response\Json
  142. * @author Tab
  143. * @date 2021/11/15 18:45
  144. */
  145. public function deleteTemplate()
  146. {
  147. $params = (new PrinterTemplateValidate())->post()->goCheck('deleteTemplate');
  148. $result = PrinterLogic::deleteTemplate($params);
  149. if ($result) {
  150. return JsonService::success('删除成功', [], 1, 1);
  151. }
  152. return JsonService::fail(PrinterLogic::getError());
  153. }
  154. /**
  155. * @notes 模板列表
  156. * @return \think\response\Json
  157. * @author Tab
  158. * @date 2021/11/15 18:49
  159. */
  160. public function printerTemplateLists()
  161. {
  162. return JsonService::dataLists(new PrinterTemplateList());
  163. }
  164. /**
  165. * @notes 获取模板详情
  166. * @return \think\response\Json
  167. * @author Tab
  168. * @date 2021/11/16 17:54
  169. */
  170. public function templateDetail()
  171. {
  172. $params = (new PrinterTemplateValidate())->goCheck('templateDetail');
  173. $result = PrinterLogic::templateDetail($params);
  174. return JsonService::data($result);
  175. }
  176. /**
  177. * @notes 测试打印机
  178. * @return \think\response\Json
  179. * @author Tab
  180. * @date 2021/11/16 17:56
  181. */
  182. public function testPrinter() {
  183. $params = (new PrinterValidate())->post()->goCheck('testPrinter');
  184. $result = PrinterLogic::testPrinter($params);
  185. if ($result) {
  186. return JsonService::success('测试完成', [], 1, 1);
  187. }
  188. return JsonService::fail(PrinterLogic::getError());
  189. }
  190. /**
  191. * @notes 自动打印状态切换
  192. * @return \think\response\Json
  193. * @author Tab
  194. * @date 2021/11/17 10:31
  195. */
  196. public function autoPrint()
  197. {
  198. $params = (new PrinterValidate())->post()->goCheck('autoPrint');
  199. $result = PrinterLogic::autoPrint($params);
  200. if ($result) {
  201. return JsonService::success('修改成功', [], 1, 1);
  202. }
  203. return JsonService::fail(PrinterLogic::getError());
  204. }
  205. }