|
|
@@ -22,17 +22,21 @@ class LabelController extends BaseController
|
|
|
if (empty($ptItemId)) {
|
|
|
util::fail('没有花材信息');
|
|
|
}
|
|
|
-print_r($arr);die;
|
|
|
+
|
|
|
$list = LabelClass::getAllByCondition(['mainId' => $this->mainId, 'use' => 0], null, '*');
|
|
|
- $has = [];
|
|
|
if (!empty($list)) {
|
|
|
$has = array_column($list, 'epc');
|
|
|
+ $common = array_intersect($arr, $has);
|
|
|
+ if (!empty($common)) {
|
|
|
+ $currentLabel = $common[0] ?? '';
|
|
|
+ util::fail('标签已经添加过了:' . $currentLabel);
|
|
|
+ }
|
|
|
}
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
foreach ($arr as $epc) {
|
|
|
-
|
|
|
+ LabelClass::add(['mainId' => $this->mainId, 'epc' => $epc, 'itemId' => $ptItemId]);
|
|
|
}
|
|
|
$transaction->commit();
|
|
|
util::complete('操作成功');
|