PlantCgController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace hd\controllers;
  3. use biz\shop\classes\ShopExtClass;
  4. use bizHd\goods\classes\PlantCgClass;
  5. use bizHd\goods\classes\PlantCgItemClass;
  6. use common\components\printUtil;
  7. use common\components\util;
  8. use Yii;
  9. class PlantCgController extends BaseController
  10. {
  11. //打印全部 ssh 20220602
  12. public function actionPrintAll()
  13. {
  14. $get = Yii::$app->request->get();
  15. $orderSn = $get['orderSn'] ?? 0;
  16. $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  17. if (empty($itemList)) {
  18. util::fail('没有商品');
  19. }
  20. $shopId = $this->shopId;
  21. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  22. $printLabelSn = $ext->printLabelSn ?? '';
  23. if (empty($printLabelSn)) {
  24. util::fail('请设置标签打印机');
  25. }
  26. $p = new printUtil($printLabelSn);
  27. foreach ($itemList as $key => $item) {
  28. $name = $item->name ?? '';
  29. $num = !empty($item->num) ? floatval($item->num) : 0;
  30. if (empty($num)) {
  31. util::fail('商品数量错误');
  32. }
  33. $goodsSn = $item->goodsSn ?? '';
  34. //$price = floatval($item->price);
  35. $content = '<TEXT x="30" y="45" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
  36. $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $goodsSn . '</BC128>';
  37. if ($key % 2 == 1) {
  38. $content .= '<TEXT x="6" y="0" font="12" w="2" h="2" r="0">.</TEXT>';
  39. }
  40. //$content .= '<TEXT x="30" y="250" font="11" w="2" h="2" r="0">' . $price . '</TEXT>';
  41. $p->times = $num;
  42. $p->printLabelMsg($content);
  43. }
  44. util::complete();
  45. }
  46. //打印全部 ssh 20220
  47. public function actionPrintItem()
  48. {
  49. $get = Yii::$app->request->get();
  50. $id = $get['id'] ?? 0;
  51. $item = PlantCgItemClass::getById($id, true);
  52. if (empty($item)) {
  53. util::fail('没有找到花材');
  54. }
  55. $name = $item->name ?? '';
  56. $num = !empty($item->num) ? floatval($item->num) : 0;
  57. if (empty($num)) {
  58. util::fail('没有花材数量');
  59. }
  60. $shopId = $this->shopId;
  61. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  62. $printLabelSn = $ext->printLabelSn ?? '';
  63. if (empty($printLabelSn)) {
  64. util::fail('请设置标签打印机');
  65. }
  66. $p = new printUtil($printLabelSn);
  67. $goodsSn = $item->goodsSn ?? '';
  68. //$price = floatval($item->price) ?? 0;
  69. $content = '<TEXT x="30" y="45" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
  70. $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $goodsSn . '</BC128>';
  71. //$content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">' . $price . '</TEXT>';
  72. $p->times = $num;
  73. $p->printLabelMsg($content);
  74. util::complete();
  75. }
  76. //采购详情 ssh 2020521
  77. public function actionDetail()
  78. {
  79. $get = Yii::$app->request->get();
  80. $id = $get['id'] ?? 0;
  81. $cg = PlantCgClass::getById($id, true);
  82. if ($cg->mainId != $this->mainId) {
  83. util::fail('没有权限');
  84. }
  85. $itemList = PlantCgItemClass::getItemList($cg);
  86. $data = [];
  87. $data['hasDebtPay'] = 0;
  88. $data['balance'] = 0;
  89. $data['info'] = $cg;
  90. $data['itemList'] = $itemList;
  91. util::success($data);
  92. }
  93. //采购记录 ssh 20220521
  94. public function actionList()
  95. {
  96. $get = Yii::$app->request->get();
  97. $where = ['shopId' => $this->shopId];
  98. $status = $get['status'] ?? 0;
  99. if (!empty($status)) {
  100. $where['status'] = $status;
  101. }
  102. $respond = PlantCgClass::getCgList($where);
  103. $respond['shop'] = $this->shop;
  104. util::success($respond);
  105. }
  106. //获取采购详情 ssh 20220508
  107. public function actionGetFullInfo()
  108. {
  109. $id = Yii::$app->request->get('id');
  110. $cg = PlantCgClass::getById($id, true);
  111. PlantCgClass::valid($cg, $this->mainId);
  112. $orderSn = $cg->orderSn ?? '';
  113. $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
  114. util::success(['info' => $cg, 'itemList' => $itemList]);
  115. }
  116. }