diff --git a/composer.json b/composer.json index 7451408..827d7e2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "laravel/lumen", - "version": "4.4.1", + "version": "4.4.2", "description": "The Laravel Lumen Framework.", "keywords": ["framework", "laravel", "lumen"], "license": "MIT", diff --git a/src/DistributionBundle/Http/Api/V1/Action/Distributor.php b/src/DistributionBundle/Http/Api/V1/Action/Distributor.php index 0636663..e3375c9 100644 --- a/src/DistributionBundle/Http/Api/V1/Action/Distributor.php +++ b/src/DistributionBundle/Http/Api/V1/Action/Distributor.php @@ -1769,6 +1769,15 @@ class Distributor extends Controller $pageSize = $request->get('pageSize') ?: -1; $page = $request->get('page') ?: 1; $data = $distributorItemsService->getDistributorRelItemList($filter, $pageSize, $page, ['item_id' => 'desc'], false); + if (!empty($data['list'])) { + $company = (new CompanysActivationEgo())->check($companyId); + if (($company['product_model'] ?? '') === 'standard') { + $data['list'] = $distributorItemsService->applyMultiSpecTotalStoreForDistributorRelItemList($data['list']); + } else { + $itemsService = new ItemsService(); + $data['list'] = $itemsService->applyMultiSpecTotalStoreForItemList($data['list']); + } + } $data['warning_store'] = $warningStore; $data['filter'] = $filter; diff --git a/src/DistributionBundle/Http/FrontApi/V1/Action/Distributor.php b/src/DistributionBundle/Http/FrontApi/V1/Action/Distributor.php index 7a70833..1c9c738 100644 --- a/src/DistributionBundle/Http/FrontApi/V1/Action/Distributor.php +++ b/src/DistributionBundle/Http/FrontApi/V1/Action/Distributor.php @@ -795,7 +795,7 @@ class Distributor extends BaseController $filter = []; - $filter['is_valid'] = 'true'; + // $filter['is_valid'] = 'true'; $type = $request->input('type', 0); // 过滤条件 $noHaving = false; // 是否过滤离用户的经纬度比较远的店铺 【true 不过滤】【false 过滤】 @@ -928,7 +928,12 @@ class Distributor extends BaseController $filter['distributor_self'] = 0; // $filter['is_valid'] = 'true'; - $filter['is_valid'] = ['true', 'false']; + if ($request->input('is_valid')) { + $filter['is_valid'] = $request->input('is_valid'); + } else { + $filter['is_valid'] = ['true', 'false']; + } + if ($request->input('get_shop')) { $filter['shop_id|neq'] = ''; } diff --git a/src/DistributionBundle/Services/DistributorItemsService.php b/src/DistributionBundle/Services/DistributorItemsService.php index 828d7c0..df3672a 100644 --- a/src/DistributionBundle/Services/DistributorItemsService.php +++ b/src/DistributionBundle/Services/DistributorItemsService.php @@ -429,6 +429,115 @@ class DistributorItemsService return $result; } + /** + * 店铺关联商品列表:多规格(nospec=false)时汇总同一 goods 下全部子规格的「有效库存」。 + * 与 GoodsBundle\Services\ItemsService::applyMultiSpecTotalStoreForItemList 对齐思路, + * 并按 distribution_distributor_items.is_total_store 区分总部库存(items.store)与店铺库存(关联表 store)。 + * + * @param array $list getDistributorRelItemList 等返回的行(须含 company_id、goods_id、distributor_id、nospec、store) + * @return array + */ + public function applyMultiSpecTotalStoreForDistributorRelItemList(array $list) + { + if (!$list) { + return $list; + } + $companyId = $list[0]['company_id'] ?? null; + if ($companyId === null || $companyId === '') { + return $list; + } + $distributorId = (int) ($list[0]['distributor_id'] ?? 0); + + $multiGoodsIds = []; + foreach ($list as $row) { + if (!$this->isMultiSpecNospecForStore($row['nospec'] ?? null)) { + continue; + } + $gid = $row['goods_id'] ?? null; + if ($gid !== null && $gid !== '') { + $multiGoodsIds[$gid] = true; + } + } + if (!$multiGoodsIds) { + return $list; + } + + $goodsIdList = array_keys($multiGoodsIds); + $rsGoods = $this->itemsRepository->getLists( + ['company_id' => $companyId, 'goods_id' => $goodsIdList], + 'goods_id, item_id, store' + ); + if (!$rsGoods) { + return $list; + } + + $itemsByGoods = []; + foreach ($rsGoods as $g) { + $itemsByGoods[$g['goods_id']][] = $g; + } + + $allItemIds = array_unique(array_column($rsGoods, 'item_id')); + $dRel = $this->entityRepository->lists( + [ + 'company_id' => $companyId, + 'distributor_id' => $distributorId, + 'item_id' => $allItemIds, + ], + [], + -1, + 1 + ); + $dByItemId = array_column($dRel['list'] ?? [], null, 'item_id'); + + $totalByGoodsId = []; + foreach ($itemsByGoods as $goodsId => $skuRows) { + $sum = 0; + foreach ($skuRows as $sku) { + $iid = $sku['item_id']; + if (!isset($dByItemId[$iid])) { + continue; + } + $di = $dByItemId[$iid]; + if ($this->isDistributorRowUsingTotalStore($di)) { + $sum += (int) ($sku['store'] ?? 0); + } else { + $sum += (int) ($di['store'] ?? 0); + } + } + $totalByGoodsId[$goodsId] = $sum; + } + + foreach ($list as $k => $v) { + if (!$this->isMultiSpecNospecForStore($v['nospec'] ?? null)) { + continue; + } + $gid = $v['goods_id'] ?? null; + if ($gid === null || $gid === '') { + continue; + } + if (array_key_exists($gid, $totalByGoodsId)) { + $list[$k]['store'] = $totalByGoodsId[$gid]; + } + } + + return $list; + } + + /** + * @param mixed $nospec 与 Items 一致:true 为单规格,false/0/'false' 为多规格 + */ + private function isMultiSpecNospecForStore($nospec): bool + { + return $nospec === false || $nospec === 'false' || $nospec === 0 || $nospec === '0'; + } + + private function isDistributorRowUsingTotalStore(array $distributorItemRow): bool + { + $v = $distributorItemRow['is_total_store'] ?? false; + + return $v === true || $v === 'true' || $v === 1 || $v === '1'; + } + // 获取产地国信息 private function getorigincountry($list, $company_id) { @@ -790,6 +899,9 @@ class DistributorItemsService $result['list'] = $em->select('i.*')->execute()->fetchAll(); $result['list'] = $this->getDistributorSkuReplace($companyId, $distributorId, $result['list'], true); + // 多语言 + $service = new MultiLangService(); + $result['list'] = $service->getListAddLang($result['list'],['item_name'],'items',$this->getLang(),'item_id'); } else { $result['list'] = []; } diff --git a/src/EspierBundle/Services/Export/TradeExportService.php b/src/EspierBundle/Services/Export/TradeExportService.php index 308fdc4..9a2c380 100644 --- a/src/EspierBundle/Services/Export/TradeExportService.php +++ b/src/EspierBundle/Services/Export/TradeExportService.php @@ -177,13 +177,12 @@ class TradeExportService implements ExportFileInterface $orderList[$key][$k] = $value[$k] / 100; } } elseif ($k == 'payPoint') { - // 新增:处理订单实付积分 - if (isset($value['payType']) && $value['payType'] == 'point') { - // 积分支付时,订单实付积分 = payFee 的值(积分无需除以100) - $orderList[$key][$k] = isset($value['payFee']) ? $value['payFee'] : 0; + // 现金/混合支付时,订单实付积分取订单主表 point_use + if (isset($value['payType']) && $value['payType'] != 'point') { + $orderList[$key][$k] = $value['pointUse'] ?? $value['point_use'] ?? 0; } else { - // 非积分支付时,订单实付积分为0 - $orderList[$key][$k] = 0; + // 纯积分支付时,兼容使用交易单 payFee 作为积分值 + $orderList[$key][$k] = isset($value['payFee']) ? $value['payFee'] : 0; } } elseif (in_array($k, ['timeStart', 'timeExpire']) && isset($value[$k]) && $value[$k]) { $orderList[$key][$k] = date('Y-m-d H:i:s', $value[$k]); diff --git a/src/GoodsBundle/Http/Api/V1/Action/Items.php b/src/GoodsBundle/Http/Api/V1/Action/Items.php index 2285067..bcdb3cf 100644 --- a/src/GoodsBundle/Http/Api/V1/Action/Items.php +++ b/src/GoodsBundle/Http/Api/V1/Action/Items.php @@ -2614,12 +2614,11 @@ class Items extends BaseController $filter['audit_status'] = 'approved'; $filter['item_type'] = 'normal'; - if (isset($params['keywords']) && $params['keywords']) { - $filter['or'] = [ - 'item_name|contains' => $params['keywords'], - 'item_bn' => $params['keywords'], - 'barcode' => $params['keywords'], - ]; + if (isset($params['keywords'])) { + $kw = trim((string) $params['keywords']); + if ($kw !== '') { + $filter['keywords'] = $kw; + } } if (isset($params['item_name']) && $params['item_name']) { @@ -2638,6 +2637,7 @@ class Items extends BaseController $pageSize = intval($params['pageSize']); $itemsService = new ItemsService(); + $filter = $itemsService->_filter($filter); $company = (new CompanysActivationEgo())->check($filter['company_id']); if ($filter['distributor_id'] == 0 || $company['product_model'] == 'platform') { $result = $itemsService->getSkuItemsList($filter, $page, $pageSize); diff --git a/src/GoodsBundle/Services/ItemsService.php b/src/GoodsBundle/Services/ItemsService.php index 42c80d3..ff1b20a 100644 --- a/src/GoodsBundle/Services/ItemsService.php +++ b/src/GoodsBundle/Services/ItemsService.php @@ -2504,6 +2504,7 @@ class ItemsService $or = [ 'or'=>[ 'item_bn|contains'=> $filter['keywords'], + 'barcode'=> $filter['keywords'], // ['item_name|contains'=> $filter['keywords']], ] ]; diff --git a/src/OrdersBundle/Services/TradeService.php b/src/OrdersBundle/Services/TradeService.php index 5b389a6..9729cf1 100644 --- a/src/OrdersBundle/Services/TradeService.php +++ b/src/OrdersBundle/Services/TradeService.php @@ -347,6 +347,8 @@ class TradeService implements InterfacesTrade $value['receipt_type'] = $orderListData[$value['orderId']]['receipt_type']; $value['order_holder'] = $orderListData[$value['orderId']]['order_holder']; $value['self_delivery_fee'] = $orderListData[$value['orderId']]['self_delivery_fee'] ?? 0; + $value['point_use'] = $orderListData[$value['orderId']]['point_use'] ?? 0; + $value['pointUse'] = $orderListData[$value['orderId']]['point_use'] ?? 0; if (isset($selfDeliveryOperatorIds[$value['orderId']]) && $selfDeliveryOperatorIds[$value['orderId']] > 0) { $value['self_delivery_operator_id'] = $selfDeliveryOperatorIds[$value['orderId']] ?? 0; $value['self_delivery_operator_mobile'] = $selfDeliveryOperator[$value['self_delivery_operator_id']]['mobile'] ?? ''; diff --git a/src/PopularizeBundle/Services/BrokerageService.php b/src/PopularizeBundle/Services/BrokerageService.php index be5dc14..3408e84 100644 --- a/src/PopularizeBundle/Services/BrokerageService.php +++ b/src/PopularizeBundle/Services/BrokerageService.php @@ -348,12 +348,13 @@ class BrokerageService if (!$promoterInfo || $promoterInfo['disabled']) { continue; } - app('log')->info(':export brokerage:'.__FUNCTION__.__LINE__.': promoterInfo :' . json_encode($promoterInfo)); + // 推广员生成业绩,应不需要验证门店导购是否绑定店铺 + // app('log')->info(':export brokerage:'.__FUNCTION__.__LINE__.': promoterInfo :' . json_encode($promoterInfo)); - if($this->orderInfo['orderInfo']['distributor_id'] > 0 && !$this->checkSalespersonShop($promoterInfo['user_id'])){ - continue; - } - app('log')->info(':export brokerage:'.__FUNCTION__.__LINE__.': promoterInfo-userid OK :' . $promoterInfo['user_id']); + // if($this->orderInfo['orderInfo']['distributor_id'] > 0 && !$this->checkSalespersonShop($promoterInfo['user_id'])){ + // continue; + // } + // app('log')->info(':export brokerage:'.__FUNCTION__.__LINE__.': promoterInfo-userid OK :' . $promoterInfo['user_id']); //通用返佣比例 $ratio = $config['popularize_ratio'][$this->ratioType][$name]['ratio']; diff --git a/src/ThemeBundle/Services/PagesTemplateServices.php b/src/ThemeBundle/Services/PagesTemplateServices.php index 2968a0e..60622e4 100644 --- a/src/ThemeBundle/Services/PagesTemplateServices.php +++ b/src/ThemeBundle/Services/PagesTemplateServices.php @@ -730,6 +730,9 @@ class PagesTemplateServices } if ($pages_template_id) { + if ($distributor_id > 0 && $weapp_pages == 'index') { + $weapp_pages = 'distributor_index'; + } $filter = [ 'company_id' => $params['company_id'], 'pages_template_id' => $pages_template_id, diff --git a/src/ThirdPartyBundle/Http/ThirdApi/V1/Action/Refund.php b/src/ThirdPartyBundle/Http/ThirdApi/V1/Action/Refund.php index 9e3ce51..b2025bc 100644 --- a/src/ThirdPartyBundle/Http/ThirdApi/V1/Action/Refund.php +++ b/src/ThirdPartyBundle/Http/ThirdApi/V1/Action/Refund.php @@ -25,7 +25,7 @@ use OrdersBundle\Traits\GetOrderServiceTrait; use AftersalesBundle\Services\AftersalesService; -use ThirdPartyBundle\Services\SaasErpCentre\OrderAftersalesService; +// use ThirdPartyBundle\Services\SaasErpCentre\OrderAftersalesService; use ThirdPartyBundle\Services\SaasErpCentre\OrderRefundService; use ThirdPartyBundle\Services\SaasErpCentre\OrderService as SaasErpOrderService; use ThirdPartyBundle\Services\SaasErpCentre\Request as SaasErpRequest; @@ -68,13 +68,18 @@ class Refund extends Controller } $orderRefundSerrvice = new OrderRefundService(); - // 售后仅退款获取售后单号 + // 售后单号为空时,通过$params['refund_bn']获取售后单号 + if (!$aftersales_bn && isset($params['refund_bn'])) { + $aftersalesRefundInfo = $orderRefundSerrvice->getAftersalesRefundInfoByRefundBn($params['refund_bn']); + $aftersales_bn = $aftersalesRefundInfo['aftersales_bn'] ?? ''; + } + // 售后单号为空时,通过$params['refund_id']获取售后单号 if (!$aftersales_bn) { $aftersalesRefundInfo = $orderRefundSerrvice->getAftersalesRefundInfoByRefundBn($params['refund_id']); $aftersales_bn = $aftersalesRefundInfo['aftersales_bn'] ?? ''; } - $orderAftersalesService = new OrderAftersalesService(); + // $orderAftersalesService = new OrderAftersalesService(); try { // 无售后单 直接全额退款 未发货,取消订单,直接退款