|
|
@@ -52,23 +52,23 @@ class OrderService extends BaseService
|
|
|
$groupGoodsList = GroupGoodsClass::getAllByCondition(['groupId' => $groupId], null, '*');
|
|
|
if (!empty($groupGoodsList)) {
|
|
|
foreach ($groupGoodsList as $thisGoods) {
|
|
|
- $id = $thisGoods['id'] ?? 0;
|
|
|
+ $id = $thisGoods['goodsId'] ?? 0;
|
|
|
$property = dict::getDict('property', 'goods');
|
|
|
$num = $thisGoods['num'] ?? 0;
|
|
|
$unitType = 0;
|
|
|
$unitPrice = $thisGoods['unitPrice'] ?? 0;
|
|
|
- $product[] = ['id' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $unitPrice, 'property' => $property];
|
|
|
+ $product[] = ['productId' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $unitPrice, 'property' => $property];
|
|
|
}
|
|
|
}
|
|
|
$groupItemList = GroupItemClass::getAllByCondition(['groupId' => $groupId], null, '*');
|
|
|
if (!empty($groupItemList)) {
|
|
|
foreach ($groupItemList as $thisItem) {
|
|
|
- $id = $thisGoods['id'] ?? 0;
|
|
|
+ $id = $thisItem['itemId'] ?? 0;
|
|
|
$property = dict::getDict('property', 'item');
|
|
|
$unitType = $thisItem['unitType'] ?? 0;
|
|
|
$num = $thisItem['num'] ?? 0;
|
|
|
$unitPrice = $thisItem['unitPrice'] ?? 0;
|
|
|
- $product[] = ['id' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $unitPrice, 'property' => $property];
|
|
|
+ $product[] = ['productId' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $unitPrice, 'property' => $property];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -79,7 +79,7 @@ class OrderService extends BaseService
|
|
|
$currentGoodsIds = [];
|
|
|
$currentItemIds = [];
|
|
|
foreach ($product as $key => $val) {
|
|
|
- $currentId = $val['id'] ?? 0;
|
|
|
+ $currentId = $val['productId'] ?? 0;
|
|
|
$property = $val['property'];
|
|
|
if ($property == dict::getDict('property', 'goods')) {
|
|
|
$currentGoodsIds[] = $currentId;
|
|
|
@@ -114,10 +114,9 @@ class OrderService extends BaseService
|
|
|
$property = $val['property'];
|
|
|
$unitPrice = $val['unitPrice'] ?? 0;
|
|
|
$unitType = $val['unitType'] ?? 0;
|
|
|
- $currentId = $val['id'] ?? 0;
|
|
|
+ $currentId = $val['productId'] ?? 0;
|
|
|
$num = $val['num'] ?? 0;
|
|
|
if ($property == dict::getDict('property', 'goods')) {
|
|
|
- $goodsId = $val['id'] ?? 0;
|
|
|
$name = $goodsInfo[$currentId]['name'] ?? '';
|
|
|
$cover = $goodsInfo[$currentId]['cover'] ?? '';
|
|
|
if (!empty($groupCover)) {
|
|
|
@@ -129,7 +128,7 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
$currentGoodsData = [
|
|
|
'orderSn' => $orderSn,
|
|
|
- 'goodsId' => $goodsId,
|
|
|
+ 'goodsId' => $currentId,
|
|
|
'customId' => $customId,
|
|
|
'hdId' => $hdId,
|
|
|
'sjId' => $sjId,
|
|
|
@@ -144,14 +143,13 @@ class OrderService extends BaseService
|
|
|
//库存变化在这里
|
|
|
OrderGoodsClass::addData($currentGoodsData);
|
|
|
$groupGoodsData[] = [
|
|
|
- 'goodsId' => $goodsId,
|
|
|
+ 'goodsId' => $currentId,
|
|
|
'num' => $num,
|
|
|
'name' => $name,
|
|
|
'unitPrice' => $unitPrice,
|
|
|
];
|
|
|
}
|
|
|
if ($property == dict::getDict('property', 'item')) {
|
|
|
- $itemId = $val['id'] ?? 0;
|
|
|
$name = $itemInfo[$currentId]['name'] ?? '';
|
|
|
$cover = $itemInfo[$currentId]['cover'] ?? '';
|
|
|
if (!empty($groupCover)) {
|
|
|
@@ -182,7 +180,7 @@ class OrderService extends BaseService
|
|
|
'unitPrice' => $unitPrice,
|
|
|
'num' => $num,
|
|
|
'orderSn' => $orderSn,
|
|
|
- 'itemId' => $itemId,
|
|
|
+ 'itemId' => $currentId,
|
|
|
'ptItemId' => $ptItemId,
|
|
|
'totalNum' => $totalNum,
|
|
|
'totalPrice' => $totalPrice,
|
|
|
@@ -197,7 +195,7 @@ class OrderService extends BaseService
|
|
|
|
|
|
$groupItemData[] = [
|
|
|
'name' => $name,
|
|
|
- 'itemId' => $itemId,
|
|
|
+ 'itemId' => $currentId,
|
|
|
'ptItemId' => $ptItemId,
|
|
|
'num' => $num,
|
|
|
'unitType' => $unitType,
|
|
|
@@ -222,8 +220,8 @@ class OrderService extends BaseService
|
|
|
|
|
|
//保存组合
|
|
|
$groupName = $data['groupName'] ?? '';
|
|
|
- if (!empty($groupName)) {
|
|
|
- $groupData = ['price' => $modifyPrice, 'name' => $groupName, 'sjId' => $sjId, 'shopId' => $shopId, 'cover' => $groupCover];
|
|
|
+ if (empty($groupId) && !empty($groupName)) {
|
|
|
+ $groupData = ['price' => $modifyPrice, 'mainId' => $mainId, 'name' => $groupName, 'sjId' => $sjId, 'shopId' => $shopId, 'cover' => $groupCover];
|
|
|
$group = GroupClass::add($groupData, true);
|
|
|
$groupId = $group->id ?? 0;
|
|
|
if (!empty($groupGoodsData)) {
|
|
|
@@ -256,7 +254,6 @@ class OrderService extends BaseService
|
|
|
//保存订单
|
|
|
$returnOrder = OrderClass::addOrder($addData);
|
|
|
|
|
|
-
|
|
|
//欠款和已付款的直接完成
|
|
|
if (in_array($hasPay, [dict::getDict('hasPay', 'payed'), dict::getDict('hasPay', 'debt')])) {
|
|
|
OrderClass::payAfter($returnOrder, $payWay);
|