PlantCgController.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 2020521
  47. public function actionDetail()
  48. {
  49. $get = Yii::$app->request->get();
  50. $id = $get['id'] ?? 0;
  51. $cg = PlantCgClass::getById($id, true);
  52. if ($cg->mainId != $this->mainId) {
  53. util::fail('没有权限');
  54. }
  55. $itemList = PlantCgItemClass::getItemList($cg);
  56. $data = [];
  57. $data['hasDebtPay'] = 0;
  58. $data['balance'] = 0;
  59. $data['info'] = $cg;
  60. $data['itemList'] = $itemList;
  61. util::success($data);
  62. }
  63. //采购记录 ssh 20220521
  64. public function actionList()
  65. {
  66. $get = Yii::$app->request->get();
  67. $where = ['shopId' => $this->shopId];
  68. $status = $get['status'] ?? 0;
  69. if (!empty($status)) {
  70. $where['status'] = $status;
  71. }
  72. $respond = PlantCgClass::getCgList($where);
  73. $respond['shop'] = $this->shop;
  74. util::success($respond);
  75. }
  76. //获取采购详情 ssh 20220508
  77. public function actionGetFullInfo()
  78. {
  79. $id = Yii::$app->request->get('id');
  80. $cg = PlantCgClass::getById($id, true);
  81. PlantCgClass::valid($cg, $this->mainId);
  82. $orderSn = $cg->orderSn ?? '';
  83. $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
  84. util::success(['info' => $cg, 'itemList' => $itemList]);
  85. }
  86. }