|
|
@@ -21,7 +21,7 @@ use Yii;
|
|
|
class PurchaseOrderController extends BaseController
|
|
|
{
|
|
|
|
|
|
- public $guestAccess = ['detail'];
|
|
|
+ public $guestAccess = ['detail', 'check-seat-update', 'assign-seat'];
|
|
|
|
|
|
//打印多联 ssh 2024509
|
|
|
public function actionPrintPaper()
|
|
|
@@ -500,7 +500,7 @@ class PurchaseOrderController extends BaseController
|
|
|
$noLock = util::lock($key);
|
|
|
if ($noLock) {
|
|
|
//没有锁定,即没有在分配货位,可以进行货位分配
|
|
|
- PurchaseOrderClass::assign($order, $bookSn);
|
|
|
+ PurchaseOrderClass::assign($order);
|
|
|
util::unlock($key);
|
|
|
}
|
|
|
}
|
|
|
@@ -523,29 +523,41 @@ class PurchaseOrderController extends BaseController
|
|
|
if (empty($cg)) {
|
|
|
util::fail('没有找到采购单');
|
|
|
}
|
|
|
- if (!empty($salt)) {
|
|
|
- if ($cg->salt != $salt) {
|
|
|
- util::fail('您不能访问的采购单');
|
|
|
+ //不是待入库状态不需要分配
|
|
|
+ if ($cg->status != 3) {
|
|
|
+ util::success(['hint' => 'cg is no wait for entry']);
|
|
|
+ }
|
|
|
+ $cgBookSn = $cg->bookSn ?? 0;
|
|
|
+ if (empty($cgBookSn)) {
|
|
|
+ util::success(['hint' => 'cg bookSn is empty']);
|
|
|
+ }
|
|
|
+ $adminId = $this->adminId;
|
|
|
+ if (!empty($adminId)) {
|
|
|
+ if ($cg->mainId != $this->mainId) {
|
|
|
+ util::success(['hint' => 'cg mainId != this mainId']);
|
|
|
+ }
|
|
|
+ $shop = $this->shop;
|
|
|
+ $bookSn = $shop->bookSn ?? 0;
|
|
|
+ if ($bookSn != $cgBookSn) {
|
|
|
+ util::success(['hint' => 'shop bookSn != cg bookSn']);
|
|
|
}
|
|
|
} else {
|
|
|
- if ($cg->mainId != $this->mainId) {
|
|
|
- util::fail('不是你的采购单呢');
|
|
|
+ if ($cg->salt != $salt) {
|
|
|
+ util::success(['hint' => 'cg salt != post salt']);
|
|
|
+ }
|
|
|
+ $shopId = $cg->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::success(['hint' => 'shop empty']);
|
|
|
+ }
|
|
|
+ if ($shop->bookSn != $cgBookSn) {
|
|
|
+ util::success(['hint' => 'shop bookSn != cg bookSn o']);
|
|
|
}
|
|
|
}
|
|
|
- $shop = $this->shop;
|
|
|
- $bookSn = $shop->bookSn ?? 0;
|
|
|
- if (empty($bookSn)) {
|
|
|
- util::success([]);
|
|
|
- }
|
|
|
- //不是待入库状态不需要分配
|
|
|
- if ($cg->status != 3) {
|
|
|
- util::success([]);
|
|
|
- }
|
|
|
-
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- PurchaseOrderClass::assign($cg, $bookSn);
|
|
|
+ PurchaseOrderClass::assign($cg);
|
|
|
$transaction->commit();
|
|
|
util::complete('货位获取成功');
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -585,7 +597,7 @@ class PurchaseOrderController extends BaseController
|
|
|
//订单详情
|
|
|
public function actionDetail()
|
|
|
{
|
|
|
- $get = Yii::$app->request->get('');
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
$orderSn = $get['orderSn'] ?? '';
|
|
|
$salt = $get['salt'] ?? '';
|
|
|
$adminId = $this->adminId ?? 0;
|
|
|
@@ -605,6 +617,58 @@ class PurchaseOrderController extends BaseController
|
|
|
util::success($orderData);
|
|
|
}
|
|
|
|
|
|
+ //采购页,定时检测货位有没更新 ssh 20240709
|
|
|
+ public function actionCheckSeatUpdate()
|
|
|
+ {
|
|
|
+ util::success(['need' => 1]);
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $orderSn = $get['orderSn'] ?? '';
|
|
|
+ $salt = $get['salt'] ?? '';
|
|
|
+ if (empty($orderSn)) {
|
|
|
+ util::success(['need' => 0, 'hint' => 'empty orderSn']);
|
|
|
+ }
|
|
|
+ $cg = PurchaseOrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (empty($cg)) {
|
|
|
+ util::success(['need' => 0, 'hint' => 'empty cg info']);
|
|
|
+ }
|
|
|
+ $adminId = $this->adminId ?? 0;
|
|
|
+ $cgId = $cg->id ?? 0;
|
|
|
+ $cgBookSn = $cg->bookSn ?? 0;
|
|
|
+ if (!empty($adminId)) {
|
|
|
+ if ($cg->mainId != $this->mainId) {
|
|
|
+ util::success(['need' => 0, 'hint' => 'cgMainId != thisMainId']);
|
|
|
+ }
|
|
|
+ $shop = $this->shop;
|
|
|
+ $shopBookSn = $shop->bookSn ?? 0;
|
|
|
+ if (empty($shopBookSn)) {
|
|
|
+ util::success(['need' => 0, 'hint' => 'empty shopBookSn']);
|
|
|
+ }
|
|
|
+ if ($shopBookSn != $cgBookSn) {
|
|
|
+ util::success(['need' => 0, 'hint' => 'shopBookSn!=cgBookSn']);
|
|
|
+ }
|
|
|
+ $cacheKey = 'ghs_cg_order_staff_refresh_seat_' . $cgBookSn;
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $element = $cgId . '-' . $staffId;
|
|
|
+ $exists = Yii::$app->redis->executeCommand('SISMEMBER', [$cacheKey, $element]);
|
|
|
+ if (!empty($exists)) {
|
|
|
+ Yii::$app->redis->executeCommand('SREM', [$cacheKey, $element]);
|
|
|
+ util::success(['need' => 1]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ($cg->salt != $salt) {
|
|
|
+ util::success(['need' => 0, 'hint' => 'cg salt != post salt']);
|
|
|
+ }
|
|
|
+ $cacheKey = 'ghs_cg_order_guest_refresh_seat_' . $cgBookSn;
|
|
|
+ $exists = Yii::$app->redis->executeCommand('SISMEMBER', [$cacheKey, $cgId]);
|
|
|
+ if (!empty($exists)) {
|
|
|
+ Yii::$app->redis->executeCommand('SREM', [$cacheKey, $cgId]);
|
|
|
+ util::success(['need' => 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::success(['need' => 0, 'hint' => 'real no need']);
|
|
|
+ }
|
|
|
+
|
|
|
//修改备注
|
|
|
public function actionUpdateRemark()
|
|
|
{
|