|
|
@@ -9,7 +9,9 @@ use biz\shop\classes\ShopExtClass;
|
|
|
use bizGhs\item\classes\ItemClassClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\product\services\ProductService;
|
|
|
+use bizHd\admin\classes\ShopAdminClass;
|
|
|
use bizHd\item\classes\ItemClass;
|
|
|
+use bizHd\purchase\classes\PurchaseClass;
|
|
|
use common\components\printUtil;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
@@ -201,17 +203,21 @@ class ProductController extends BaseController
|
|
|
{
|
|
|
$shop = $this->shop ?? [];
|
|
|
$default = $shop->default ?? 0;
|
|
|
+ $join = $shop->join ?? 0;
|
|
|
$shopAdmin = $this->shopAdmin;
|
|
|
+ $adminId = $this->adminId ?? 0;
|
|
|
if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
|
|
|
util::fail('超管才能修改');
|
|
|
}
|
|
|
-
|
|
|
- $pfShopId = $shop->pfShopId ?? 0;
|
|
|
- if (!empty($pfShopId)) {
|
|
|
- util::fail('请在批发端操作');
|
|
|
+ if ($join == 0 && $default == 0) {
|
|
|
+ util::fail('当前直营分店,只能回总店修改价格');
|
|
|
}
|
|
|
-
|
|
|
- $data = Yii::$app->request->post('data', '');
|
|
|
+ //normal常规改价,cg采购改价
|
|
|
+ $changeType = Yii::$app->request->post('changeType', 'normal');
|
|
|
+ $targetId = Yii::$app->request->post('targetId', 0);
|
|
|
+ $changeParams = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name, 'changeType' => $changeType, 'targetId' => $targetId];
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $data = $post['data'] ?? '';
|
|
|
if (empty($data)) {
|
|
|
util::fail('没有修改');
|
|
|
}
|
|
|
@@ -222,6 +228,22 @@ class ProductController extends BaseController
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
+
|
|
|
+ $cg = PurchaseClass::getLockById($targetId);
|
|
|
+ if (!empty($cg)) {
|
|
|
+ if (isset($cg->mainId) == false || $cg->mainId != $this->mainId) {
|
|
|
+ util::fail('不是您的采购单');
|
|
|
+ }
|
|
|
+ //没有发货则先发货
|
|
|
+ if ($cg->status == PurchaseClass::STATUS_UN_SEND) {
|
|
|
+ $cg = PurchaseClass::orderSend($cg, [], true);
|
|
|
+ }
|
|
|
+ //确认收货并入库
|
|
|
+ if ($cg->status == PurchaseClass::STATUS_SENDING) {
|
|
|
+ PurchaseClass::takeToPutIn($cg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$ids = array_column($arr, 'id');
|
|
|
$ids = array_unique(array_filter($ids));
|
|
|
if (empty($ids)) {
|
|
|
@@ -242,32 +264,60 @@ class ProductController extends BaseController
|
|
|
}
|
|
|
$price = $product['price'];
|
|
|
$productId = $product['id'];
|
|
|
-
|
|
|
- $product = $productList[$productId] ?? [];
|
|
|
- if (empty($product)) {
|
|
|
+ $productInfo = $productList[$productId] ?? [];
|
|
|
+ if (empty($productInfo)) {
|
|
|
util::fail('没有找到花材');
|
|
|
}
|
|
|
- if (isset($product->mainId) == false || $product->mainId != $this->mainId) {
|
|
|
+ $productName = $productInfo->name ?? '';
|
|
|
+ if (isset($product['price']) == false || is_numeric($product['price']) == false || $product['price'] < 0) {
|
|
|
+ util::fail('请填写' . $productName . '的批发价');
|
|
|
+ }
|
|
|
+ if (isset($product['skPrice']) == false || is_numeric($product['skPrice']) == false || $product['skPrice'] < 0) {
|
|
|
+ util::fail('请填写' . $productName . '的零售价');
|
|
|
+ }
|
|
|
+ $skPrice = $product['skPrice'];
|
|
|
+ if (isset($product['hjPrice']) == false || is_numeric($product['hjPrice']) == false || $product['hjPrice'] < 0) {
|
|
|
+ util::fail('请填写' . $productName . '的会员价');
|
|
|
+ }
|
|
|
+ $hjPrice = $product['hjPrice'] ?? 0;
|
|
|
+ if (isset($productInfo->mainId) == false || $productInfo->mainId != $this->mainId) {
|
|
|
util::fail('无法访问');
|
|
|
}
|
|
|
- if (empty($price) || is_numeric($price) == false) {
|
|
|
- continue;
|
|
|
+ if ($hjPrice > $price) {
|
|
|
+ util::fail($productName . ' 批发价要大于会员价');
|
|
|
+ }
|
|
|
+ if ($price > $skPrice) {
|
|
|
+ util::fail($productName . ' 零售价要大于批发价');
|
|
|
}
|
|
|
- $ptItemId = $product->itemId;
|
|
|
- $staff = $this->shopAdmin;
|
|
|
- $staffName = $staff->name ?? '';
|
|
|
- $params = ['staffName' => $staffName];
|
|
|
- ItemClass::changeSinglePrice($shop, $ptItemId, $price, $params);
|
|
|
+ $ptItemId = $productInfo->itemId;
|
|
|
+ ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
|
|
|
//在首店修改需要同步到所有直营店
|
|
|
if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
|
|
|
foreach ($chainShopList as $chain) {
|
|
|
if ($chain->id == $shop->id) {
|
|
|
continue;
|
|
|
}
|
|
|
- ItemClass::changeSinglePrice($chain, $ptItemId, $price, $params);
|
|
|
+ $chainMainId = $chain->mainId ?? 0;
|
|
|
+ $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
|
|
|
+ $changeParams2 = ['staffId' => $staff->id, 'staffName' => $staff->name, 'changeType' => $changeType, 'targetId' => $targetId];
|
|
|
+ ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $hjPrice, $changeParams2);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ if (!empty($mainId)) {
|
|
|
+ //提醒零售收银台界面要刷新
|
|
|
+ $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
|
|
|
+ if (!empty($staffList)) {
|
|
|
+ foreach ($staffList as $staff) {
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ Yii::$app->redis->executeCommand('SET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
|
|
|
+ Yii::$app->redis->executeCommand('SET', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$transaction->commit();
|
|
|
util::complete('修改成功');
|
|
|
} catch (\Exception $e) {
|