PlantCgController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. $p->times = $num;
  35. $content = '<TEXT x="50" y="20" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
  36. $content .= '<BC128 x="50" y="90" h="80" s="1" r="0" n="2" w="2">' . $goodsSn . '</BC128>';
  37. if ($key % 2 == 1) {
  38. $content .= '<TEXT x="265" y="110" font="12" w="3" h="3" r="0">.</TEXT>';
  39. }
  40. $p->printLabelMsg($content);
  41. }
  42. util::complete();
  43. }
  44. //打印全部 ssh 20220
  45. public function actionPrintItem()
  46. {
  47. $get = Yii::$app->request->get();
  48. $id = $get['id'] ?? 0;
  49. $item = PlantCgItemClass::getById($id, true);
  50. if (empty($item)) {
  51. util::fail('没有找到花材');
  52. }
  53. $name = $item->name ?? '';
  54. $num = !empty($item->itemNum) ? floatval($item->itemNum) : 0;
  55. if (empty($num)) {
  56. util::fail('没有花材数量');
  57. }
  58. $shopId = $this->shopId;
  59. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  60. $printLabelSn = $ext->printLabelSn ?? '';
  61. if (empty($printLabelSn)) {
  62. util::fail('请设置条码打印机');
  63. }
  64. $p = new printUtil($printLabelSn);
  65. $goodsSn = $item->goodsSn ?? '';
  66. $p->times = $num;
  67. $content = '<TEXT x="50" y="20" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
  68. $content .= '<BC128 x="50" y="90" h="80" s="1" r="0" n="2" w="2">' . $goodsSn . '</BC128>';
  69. $p->printLabelMsg($content);
  70. util::complete();
  71. }
  72. //采购详情 ssh 2020521
  73. public function actionDetail()
  74. {
  75. $get = Yii::$app->request->get();
  76. $id = $get['id'] ?? 0;
  77. $cg = PlantCgClass::getById($id, true);
  78. if ($cg->mainId != $this->mainId) {
  79. util::fail('没有权限');
  80. }
  81. $itemList = PlantCgItemClass::getItemList($cg);
  82. $data = [];
  83. $data['hasDebtPay'] = 0;
  84. $data['balance'] = 0;
  85. $data['info'] = $cg;
  86. $data['itemList'] = $itemList;
  87. util::success($data);
  88. }
  89. //采购记录 ssh 20220521
  90. public function actionList()
  91. {
  92. $get = Yii::$app->request->get();
  93. $where = ['shopId' => $this->shopId];
  94. $status = $get['status'] ?? 0;
  95. if (!empty($status)) {
  96. $where['status'] = $status;
  97. }
  98. $respond = PlantCgClass::getCgList($where);
  99. $respond['shop'] = $this->shop;
  100. util::success($respond);
  101. }
  102. //获取采购详情 ssh 20220508
  103. public function actionGetFullInfo()
  104. {
  105. $id = Yii::$app->request->get('id');
  106. $cg = PlantCgClass::getById($id, true);
  107. PlantCgClass::valid($cg, $this->mainId);
  108. $orderSn = $cg->orderSn ?? '';
  109. $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
  110. util::success(['info' => $cg, 'itemList' => $itemList]);
  111. }
  112. }