|
|
@@ -11,6 +11,60 @@ use Yii;
|
|
|
class PurchaseOrderItemController 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();
|
|
|
+ }
|
|
|
+
|
|
|
//获取采购单的明细
|
|
|
public function actionGetItemList()
|
|
|
{
|
|
|
@@ -33,12 +87,20 @@ class PurchaseOrderItemController extends BaseController
|
|
|
$addPrice = $current['addPrice'] ?? 0;
|
|
|
$hjAddPrice = $current['hjAddPrice'] ?? 0;
|
|
|
$skMore = $current['skMore'] ?? 0;
|
|
|
- $suggestPrice = bcadd($cost, $addPrice, 2);
|
|
|
+
|
|
|
+ if (isset($info['savePrice']) && $info['savePrice'] > 0) {
|
|
|
+ $suggestPrice = $info['savePrice'] ?? 0;
|
|
|
+ $suggestSkPrice = $info['saveSkPrice'] ?? 0;
|
|
|
+ $suggestHjPrice = $info['saveHjPrice'] ?? 0;
|
|
|
+ } else {
|
|
|
+ $suggestPrice = bcadd($cost, $addPrice, 2);
|
|
|
+ $suggestSkPrice = bcadd($cost, $skMore, 2);
|
|
|
+ $suggestHjPrice = bcadd($cost, $hjAddPrice, 2);
|
|
|
+ }
|
|
|
$suggestPrice = floatval($suggestPrice);
|
|
|
- $suggestSkPrice = bcadd($cost, $skMore, 2);
|
|
|
$suggestSkPrice = floatval($suggestSkPrice);
|
|
|
- $suggestHjPrice = bcadd($cost, $hjAddPrice, 2);
|
|
|
$suggestHjPrice = floatval($suggestHjPrice);
|
|
|
+
|
|
|
$list[$key]['suggestPrice'] = $suggestPrice;
|
|
|
$list[$key]['suggestSkPrice'] = $suggestSkPrice;
|
|
|
$list[$key]['suggestHjPrice'] = $suggestHjPrice;
|