orderSn ?? ''; $sjId = $order->sjId ?? 0; $shopId = $order->shopId ?? 0; $mainId = $order->mainId ?? 0; $customName = $order->customName ?? ''; $orderId = $order->id ?? 0; $goodsList = self::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($goodsList)) { foreach ($goodsList as $goods) { $goodsId = $goods->goodsId ?? 0; $num = $goods->num ?? 0; $orderPrice = $order->orderPrice ?? 0; $fromType = $order->fromType ?? 1; $remark = $order->remark ?? ''; $orderDebtPrice = $order->remainDebtPrice ?? 0; $sendType = $order->sendType ?? 0; $thirdSn = $order->thirdSn ?? ''; $cardInfo = $order->cardInfo ?? ''; $anonymity = $order->anonymity ?? 0; $manyType = $order->manyType ?? 0; $sendNum = $order->sendNum ?? ''; $params = ['orderId' => $orderId, 'orderSn' => $orderSn, 'shopId' => $shopId, 'sendType' => $sendType, 'thirdSn' => $thirdSn, 'cardInfo' => $cardInfo, 'anonymity' => $anonymity, 'fromType' => $fromType, 'orderPrice' => $orderPrice, 'remark' => $remark, 'orderDebtPrice' => $orderDebtPrice, 'manyType' => $manyType, 'sendNum' => $sendNum, ]; $flower = $goods->flower ?? 0; //鲜花类不需要验证库存,库存可以负数,并相应生成制作单 $checkStock = $flower == 0 ? true : false; $respond = GoodsClass::decreaseStock($goodsId, $mainId, $num, $checkStock, $params); $oldStock = $respond['oldStock'] ?? 0; $newStock = $respond['newStock'] ?? 0; $data = []; $data['sjId'] = $sjId; $data['shopId'] = $shopId; $data['mainId'] = $mainId; $data['orderSn'] = $orderSn; $data['goodsId'] = $goodsId; $data['goodsNum'] = $num; $data['oldStock'] = $oldStock; $data['newStock'] = $newStock; $data['relateName'] = $customName; //搜索关键词GoodsStockRecordClass::sellGoods,可以找到相同的方法,暂时没有写在一起 GoodsStockRecordClass::sellGoods($data); } } } public static function addData($data) { return self::add($data); } //取订单 ssh 2020.1.2 public static function getGoodsListBySn($sn) { $arr = self::getAllByCondition(['orderSn' => $sn], null, '*'); if (empty($arr)) { return []; } foreach ($arr as $key => $val) { $val = business::formatOrderGoodsCover($val); $arr[$key] = $val; } return $arr; } //取订单 ssh 2020.1.2 public static function getGoodsListById($id) { $arr = self::getAllByCondition(['orderId' => $id], null, '*'); if (empty($arr)) { return []; } foreach ($arr as $key => $val) { $val = business::formatOrderGoodsCover($val); $arr[$key] = $val; } return $arr; } //批量取订单 ssh 2020.1.2 public static function getGoodsListByOrderSns($sns) { $arr = self::getAllByCondition(['orderSn' => ['in', $sns]], null, '*'); if (empty($arr)) { return []; } $data = []; foreach ($arr as $info) { $orderSn = $info['orderSn']; $info = business::formatOrderGoodsCover($info); $data[$orderSn][] = $info; } return $data; } }