|
|
@@ -962,6 +962,11 @@ class PurchaseOrderController extends BaseController
|
|
|
public function actionImportCreate()
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
$ghsId = $get['id'] ?? '';
|
|
|
$file = $_FILES['file'];
|
|
|
if (!is_uploaded_file($file['tmp_name'])) {
|
|
|
@@ -981,8 +986,6 @@ class PurchaseOrderController extends BaseController
|
|
|
$fullPathFile = $path . $newFile;
|
|
|
if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
|
|
|
|
|
|
- Yii::$app->params['errorReport'] = 1;
|
|
|
-
|
|
|
$arr = [];
|
|
|
$phpExcelFile = Yii::getAlias("@vendor/phpoffice/phpexcel/");
|
|
|
require_once($phpExcelFile . 'Classes/PHPExcel/IOFactory.php');
|
|
|
@@ -1082,43 +1085,39 @@ class PurchaseOrderController extends BaseController
|
|
|
util::fail('车销不能采购');
|
|
|
}
|
|
|
|
|
|
- Yii::$app->params['errorReport'] = 1;
|
|
|
-
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
-
|
|
|
- //合并
|
|
|
- $ghsItemInfo = PurchaseOrderClass::mergeItemInfo($ghsItemInfo);
|
|
|
- //判断花材格式,是否属于当前门店
|
|
|
- ProductClass::valid($ghsItemInfo, $this->mainId);
|
|
|
-
|
|
|
- $ghsInfo = GhsClass::getGhsInfo($ghsId);
|
|
|
- GhsClass::valid($ghsInfo, $this->shopId);
|
|
|
- $post['ghsId'] = $ghsId;
|
|
|
- $post['ghsInfo'] = json_encode($ghsInfo);
|
|
|
- $post['ghsName'] = $ghsInfo['name'] ?? '';
|
|
|
- $post['ghsAvatar'] = $ghsInfo['shortAvatar'] ?? '';
|
|
|
- $shop = $this->shop;
|
|
|
- $post['itemInfo'] = $ghsItemInfo;
|
|
|
- //0稍后入库
|
|
|
- $inType = PurchaseOrderClass::IN_TYPE_LATER;
|
|
|
- $post['inType'] = $inType;
|
|
|
- $debtStatus = $inType == 1 ? PurchaseOrderClass::DEBT_YES : PurchaseOrderClass::DEBT_UNKNOWN;
|
|
|
- $post['debt'] = $debtStatus;
|
|
|
- $order = PurchaseOrderClass::addOrder($post);
|
|
|
- $transaction->commit();
|
|
|
- util::success($order);
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- noticeUtil::push('导入失败,失败原因:' . $e->getMessage(), '15280215347');
|
|
|
- Yii::error("导入失败原因:" . $e->getMessage());
|
|
|
- $msg = $e->getMessage();
|
|
|
- util::fail('导入失败:'.$msg);
|
|
|
+ //合并
|
|
|
+ $ghsItemInfo = PurchaseOrderClass::mergeItemInfo($ghsItemInfo);
|
|
|
+ //判断花材格式,是否属于当前门店
|
|
|
+ ProductClass::valid($ghsItemInfo, $this->mainId);
|
|
|
+
|
|
|
+ $ghsInfo = GhsClass::getGhsInfo($ghsId);
|
|
|
+ GhsClass::valid($ghsInfo, $this->shopId);
|
|
|
+ $post['ghsId'] = $ghsId;
|
|
|
+ $post['ghsInfo'] = json_encode($ghsInfo);
|
|
|
+ $post['ghsName'] = $ghsInfo['name'] ?? '';
|
|
|
+ $post['ghsAvatar'] = $ghsInfo['shortAvatar'] ?? '';
|
|
|
+ $shop = $this->shop;
|
|
|
+ $post['itemInfo'] = $ghsItemInfo;
|
|
|
+ //0稍后入库
|
|
|
+ $inType = PurchaseOrderClass::IN_TYPE_LATER;
|
|
|
+ $post['inType'] = $inType;
|
|
|
+ $debtStatus = $inType == 1 ? PurchaseOrderClass::DEBT_YES : PurchaseOrderClass::DEBT_UNKNOWN;
|
|
|
+ $post['debt'] = $debtStatus;
|
|
|
+ $order = PurchaseOrderClass::addOrder($post);
|
|
|
+ $transaction->commit();
|
|
|
+ util::success($order);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ util::fail('导入失败了哦!');
|
|
|
}
|
|
|
- } else {
|
|
|
- util::fail('导入失败了哦!');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ noticeUtil::push('导入失败,失败原因:' . $e->getMessage(), '15280215347');
|
|
|
+ Yii::error("导入失败原因:" . $e->getMessage());
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ util::fail('导入失败:'.$msg);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|