| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace ghs\controllers;
- use bizGhs\order\classes\OrderClass;
- use bizGhs\order\classes\OrderItemClass;
- use bizGhs\order\services\OrderService;
- use bizGhs\product\classes\ProductClass;
- use common\components\imgUtil;
- use common\components\util;
- use Yii;
- class OrderItemController extends BaseController
- {
- public $guestAccess = [];
- //重选花材 ssh 2021.3.2
- public function actionReset()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $product = $post['product'] ?? '[]';
- $product = json_decode($product, true);
- //检查花材是否都是同家门店的
- ProductClass::valid($product, $this->mainId);
- $info = OrderService::getOrderInfo($id);
- OrderClass::valid($info, $this->shopId);
- //添加修改花材
- $orderSn = $info['orderSn'] ?? '';
- OrderItemClass::replaceItem($orderSn, $product);
- util::complete();
- }
- //修改花材时获取订单花材和花材基本信息的组合 ssh 20210809
- public function actionGetOrderProduct()
- {
- $id = Yii::$app->request->get('id', 0);
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $orderSn = $order->orderSn ?? '';
- $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', 'productId');
- $ids = array_column($itemList, 'productId');
- if (empty($ids)) {
- util::fail('没有找到花材');
- }
- $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
- if (empty($productList)) {
- util::fail('没有找到花材信息');
- }
- foreach ($productList as $key => $product) {
- $productId = $product['id'] ?? 0;
- $currentItem = $itemList[$productId] ?? [];
- $bigCount = $currentItem['bigNum'] ?? 0;
- $smallCount = $currentItem['smallNum'] ?? 0;
- $userPrice = $currentItem['userPrice'] ?? 0;
- $productList[$key]['bigCount'] = $bigCount;
- $productList[$key]['smallCount'] = $smallCount;
- $productList[$key]['userPrice'] = $userPrice;
- $cover = imgUtil::groupImg($product['cover']);
- $productList[$key]['cover'] = $cover;
- $bigPrice = $product['unitPrice'] ?? 0;
- $smallPrice = $product['smallUnitPrice'] ?? 0;
- $productList[$key]['bigPrice'] = $bigPrice;
- $productList[$key]['smallPrice'] = $smallPrice;
- $productList[$key]['cover'] = $cover;
- }
- util::success(['productList' => array_values($productList)]);
- }
- //根据花材id取订单列表 ssh 20211011
- public function actionGetOrderInfoList()
- {
- $get = Yii::$app->request->get();
- $productId = $get['productId'] ?? 0;
- $product = ProductClass::getById($productId, true);
- ProductClass::check($product, $this->mainId);
- $where = ['shopId' => $this->shopId, 'productId' => $productId];
- $respond = OrderItemClass::getOrderInfoList($where);
- util::success($respond);
- }
- }
|