|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
+use bizHd\product\classes\ProductClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
use common\components\imgUtil;
|
|
|
@@ -11,6 +12,60 @@ use common\components\util;
|
|
|
class CgItemController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //预存价格 ssh 20230725
|
|
|
+ public function actionSaveCgPrice()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $data = $post['data'] ?? '';
|
|
|
+ if (empty($data)) {
|
|
|
+ util::fail('没有修改');
|
|
|
+ }
|
|
|
+ $arr = json_decode($data, true);
|
|
|
+ if (empty($arr)) {
|
|
|
+ util::fail('没有修改哦');
|
|
|
+ }
|
|
|
+ $cgId = $post['cgId'] ?? 0;
|
|
|
+ $cg = PurchaseOrderClass::getById($cgId, true);
|
|
|
+ if (empty($cg)) {
|
|
|
+ util::fail('没有找到采购单');
|
|
|
+ }
|
|
|
+ if ($cg->mainId != $this->mainId) {
|
|
|
+ util::fail('没有权限');
|
|
|
+ }
|
|
|
+ $orderSn = $cg->orderSn ?? '';
|
|
|
+ $cgItemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (empty($cgItemList)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ $new = [];
|
|
|
+ foreach ($arr as $product) {
|
|
|
+ $currentId = $product['id'] ?? 0;
|
|
|
+ $savePrice = $product['savePrice'] ?? 0;
|
|
|
+ $saveSkPrice = $product['saveSkPrice'] ?? 0;
|
|
|
+ $saveHjPrice = $product['saveHjPrice'] ?? 0;
|
|
|
+ $new[$currentId]['savePrice'] = $savePrice;
|
|
|
+ $new[$currentId]['saveSkPrice'] = $saveSkPrice;
|
|
|
+ $new[$currentId]['saveHjPrice'] = $saveHjPrice;
|
|
|
+ }
|
|
|
+ foreach ($cgItemList as $cgItem) {
|
|
|
+ $thisId = $cgItem->id ?? 0;
|
|
|
+ if (isset($new[$thisId]) == false) {
|
|
|
+ util::fail('有花材没有价格');
|
|
|
+ }
|
|
|
+ $info = $new[$thisId];
|
|
|
+ $savePrice = $info['savePrice'] ?? 0;
|
|
|
+ $saveSkPrice = $info['saveSkPrice'] ?? 0;
|
|
|
+ $saveHjPrice = $info['saveHjPrice'] ?? 0;
|
|
|
+ $cgItem->savePrice = $savePrice;
|
|
|
+ $cgItem->saveSkPrice = $saveSkPrice;
|
|
|
+ $cgItem->saveHjPrice = $saveHjPrice;
|
|
|
+ $cgItem->save();
|
|
|
+ }
|
|
|
+ $cg->hasSavePrice = 1;
|
|
|
+ $cg->save();
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
//采购成功后改价时获取列表 ssh 2023311
|
|
|
public function actionGetCgItemInfo()
|
|
|
{
|
|
|
@@ -26,11 +81,41 @@ class CgItemController extends BaseController
|
|
|
$orderSn = $cg->orderSn ?? '';
|
|
|
$list = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
|
|
|
if (!empty($list)) {
|
|
|
+ $productIdList = array_column($list, 'productId');
|
|
|
+ $itemList = ProductClass::getByIds($productIdList, null, 'id');
|
|
|
foreach ($list as $key => $item) {
|
|
|
- $shortCover = $item['cover'] ?? '';
|
|
|
- $cover = imgUtil::groupImg($shortCover);
|
|
|
- $list[$key]['cover'] = $cover;
|
|
|
- $list[$key]['shortCover'] = $shortCover;
|
|
|
+
|
|
|
+ $productId = $item['productId'] ?? 0;
|
|
|
+ $cost = $item['xhUnitPrice'] ?? 0;
|
|
|
+ $cost = round($cost);
|
|
|
+ $current = $itemList[$productId] ?? [];
|
|
|
+ $addPrice = $current['addPrice'] ?? 0;
|
|
|
+ $hjAddPrice = $current['hjAddPrice'] ?? 0;
|
|
|
+ $skMore = $current['skMore'] ?? 0;
|
|
|
+
|
|
|
+ if (isset($item['savePrice']) && $item['savePrice'] > 0) {
|
|
|
+ $suggestPrice = $item['savePrice'] ?? 0;
|
|
|
+ $suggestSkPrice = $item['saveSkPrice'] ?? 0;
|
|
|
+ $suggestHjPrice = $item['saveHjPrice'] ?? 0;
|
|
|
+ } else {
|
|
|
+ $suggestPrice = bcadd($cost, $addPrice, 2);
|
|
|
+ $suggestSkPrice = bcadd($cost, $skMore, 2);
|
|
|
+ $suggestHjPrice = bcadd($cost, $hjAddPrice, 2);
|
|
|
+ }
|
|
|
+ $suggestPrice = floatval($suggestPrice);
|
|
|
+ $suggestSkPrice = floatval($suggestSkPrice);
|
|
|
+ $suggestHjPrice = floatval($suggestHjPrice);
|
|
|
+
|
|
|
+ $list[$key]['suggestPrice'] = $suggestPrice;
|
|
|
+ $list[$key]['suggestSkPrice'] = $suggestSkPrice;
|
|
|
+ $list[$key]['suggestHjPrice'] = $suggestHjPrice;
|
|
|
+ $list[$key]['skMore'] = $skMore;
|
|
|
+ $list[$key]['addPrice'] = $addPrice;
|
|
|
+ $list[$key]['hjAddPrice'] = $hjAddPrice;
|
|
|
+ //修改之前的批发价
|
|
|
+ $beforeModifyPrice = $current['price'] ?? 0;
|
|
|
+ $list[$key]['beforeModifyPrice'] = $beforeModifyPrice;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
$shop = $this->shop;
|