| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- namespace hd\controllers;
- use biz\shop\classes\ShopExtClass;
- use bizHd\goods\classes\PlantCgClass;
- use bizHd\goods\classes\PlantCgItemClass;
- use common\components\printUtil;
- use common\components\util;
- use Yii;
- class PlantCgController extends BaseController
- {
- //打印全部 ssh 20220602
- public function actionPrintAll()
- {
- $get = Yii::$app->request->get();
- $orderSn = $get['orderSn'] ?? 0;
- $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
- if (empty($itemList)) {
- util::fail('没有商品');
- }
- $shopId = $this->shopId;
- $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
- $printLabelSn = $ext->printLabelSn ?? '';
- if (empty($printLabelSn)) {
- util::fail('请设置标签打印机');
- }
- $p = new printUtil($printLabelSn);
- foreach ($itemList as $key => $item) {
- $name = $item->name ?? '';
- $num = !empty($item->num) ? floatval($item->num) : 0;
- if (empty($num)) {
- util::fail('商品数量错误');
- }
- $goodsSn = $item->goodsSn ?? '';
- //$price = floatval($item->price);
- $content = '<TEXT x="30" y="45" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
- $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $goodsSn . '</BC128>';
- if ($key % 2 == 1) {
- $content .= '<TEXT x="6" y="0" font="12" w="2" h="2" r="0">.</TEXT>';
- }
- //$content .= '<TEXT x="30" y="250" font="11" w="2" h="2" r="0">' . $price . '</TEXT>';
- $p->times = $num;
- $p->printLabelMsg($content);
- }
- util::complete();
- }
- //打印全部 ssh 20220
- public function actionPrintItem()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $item = PlantCgItemClass::getById($id, true);
- if (empty($item)) {
- util::fail('没有找到花材');
- }
- $name = $item->name ?? '';
- $num = !empty($item->num) ? floatval($item->num) : 0;
- if (empty($num)) {
- util::fail('没有花材数量');
- }
- $shopId = $this->shopId;
- $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
- $printLabelSn = $ext->printLabelSn ?? '';
- if (empty($printLabelSn)) {
- util::fail('请设置标签打印机');
- }
- $p = new printUtil($printLabelSn);
- $goodsSn = $item->goodsSn ?? '';
- //$price = floatval($item->price) ?? 0;
- $content = '<TEXT x="30" y="45" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
- $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $goodsSn . '</BC128>';
- //$content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">' . $price . '</TEXT>';
- $p->times = $num;
- $p->printLabelMsg($content);
- util::complete();
- }
- //采购详情 ssh 2020521
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $cg = PlantCgClass::getById($id, true);
- if ($cg->mainId != $this->mainId) {
- util::fail('没有权限');
- }
- $itemList = PlantCgItemClass::getItemList($cg);
- $data = [];
- $data['hasDebtPay'] = 0;
- $data['balance'] = 0;
- $data['info'] = $cg;
- $data['itemList'] = $itemList;
- util::success($data);
- }
- //采购记录 ssh 20220521
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = ['shopId' => $this->shopId];
- $status = $get['status'] ?? 0;
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $respond = PlantCgClass::getCgList($where);
- $respond['shop'] = $this->shop;
- util::success($respond);
- }
- //获取采购详情 ssh 20220508
- public function actionGetFullInfo()
- {
- $id = Yii::$app->request->get('id');
- $cg = PlantCgClass::getById($id, true);
- PlantCgClass::valid($cg, $this->mainId);
- $orderSn = $cg->orderSn ?? '';
- $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
- util::success(['info' => $cg, 'itemList' => $itemList]);
- }
- }
|