|
|
@@ -2,11 +2,10 @@
|
|
|
|
|
|
namespace console\controllers;
|
|
|
|
|
|
-use biz\shop\classes\ShopClass;
|
|
|
-use biz\sj\classes\SjClass;
|
|
|
-use bizGhs\admin\classes\AdminClass;
|
|
|
-use bizHd\saas\classes\ApplyClass;
|
|
|
-use bizHd\saas\services\ApplyService;
|
|
|
+use bizGhs\item\classes\ItemClassClass;
|
|
|
+use bizGhs\product\classes\ProductClass;
|
|
|
+use bizGhs\shop\classes\ShopAdminClass;
|
|
|
+use bizGhs\shop\classes\ShopClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
@@ -22,7 +21,15 @@ class ImportItemController extends Controller
|
|
|
ini_set('memory_limit', '2045M');
|
|
|
set_time_limit(0);
|
|
|
|
|
|
- $str = <<<CUSTOM
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+
|
|
|
+
|
|
|
+ $str = <<<CUSTOM
|
|
|
安红-拍市A A 20枝/扎 20 拍前预售单头 100 AHPSA
|
|
|
安红-拍市B B 20枝/扎 20 拍前预售单头 101 AHPSB
|
|
|
安红-拍市C C 20枝/扎 20 拍前预售单头 102 AHPSC
|
|
|
@@ -4850,22 +4857,133 @@ class ImportItemController extends Controller
|
|
|
奶油杯-滇岸花语E E 20枝/扎 20 姚安花拍单头 4924 NYBDAHYE
|
|
|
CUSTOM;
|
|
|
|
|
|
- $str = trim($str);
|
|
|
- $arr = explode('
|
|
|
+ $mainId = 42490;
|
|
|
+ $shopId = 42756;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $str = <<<CUSTOM
|
|
|
+奶油杯-滇岸花语C C 20枝/扎 20 花拍单头 4922 NYBDAHYC
|
|
|
+奶油杯-滇岸花语D D 20枝/扎 20 配叶类 4923 NYBDAHYD
|
|
|
+奶油杯-滇岸花语E E 20枝/扎 20 绣球 4924 NYBDAHYE
|
|
|
+CUSTOM;
|
|
|
+ $mainId = 644;
|
|
|
+ $shopId = 36523;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $classList = ItemClassClass::getAllByCondition(['mainId' => $mainId], null, '*', 'name');
|
|
|
+
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ $shopName = $shop->shopName ?? '';
|
|
|
+
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ if ($shopName != '集花舍') {
|
|
|
+ echo '不是集花舍';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+ $staffId = 167182;
|
|
|
+ $cover = 'default-img.png';
|
|
|
+ } else {
|
|
|
+ if ($shopName != '好运鲜花批发') {
|
|
|
+ echo '不是好运鲜花批发';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+ $staffId = 126272;
|
|
|
+ $cover = 'item_class/bh.jpeg';
|
|
|
+ }
|
|
|
+ $staff = ShopAdminClass::getByCondition(['id' => $staffId, 'mainId' => $mainId], true);
|
|
|
+ if (empty($staff)) {
|
|
|
+ util::fail('没有找到员工信息');
|
|
|
+ }
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+ $adminId = $staff->adminId ?? 0;
|
|
|
+ if (empty($adminId)) {
|
|
|
+ util::fail('没有adminId');
|
|
|
+ }
|
|
|
+
|
|
|
+ $str = trim($str);
|
|
|
+ $arr = explode('
|
|
|
', $str);
|
|
|
- foreach ($arr as $key => $val) {
|
|
|
- $val = trim($val);
|
|
|
- $ls = explode(' ', $val);
|
|
|
- $count = count($ls);
|
|
|
- if ($count != 7) {
|
|
|
- echo $val;
|
|
|
- die;
|
|
|
+ foreach ($arr as $key => $val) {
|
|
|
+ $val = trim($val);
|
|
|
+ $ls = explode(' ', $val);
|
|
|
+ $count = count($ls);
|
|
|
+ if ($count != 7) {
|
|
|
+ echo $val;
|
|
|
+ die;
|
|
|
+ }
|
|
|
+ $name = $ls[0] ?? '';
|
|
|
+ $ratio = $ls[3] ?? 20;
|
|
|
+ $catName = $ls[4] ?? '';
|
|
|
+ $catName = trim($catName);
|
|
|
+ $order = $ls[5] ?? 100;
|
|
|
+
|
|
|
+ if (!isset($classList[$catName])) {
|
|
|
+ echo $catName . ' 这个分类系统里没有';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+ $classInfo = $classList[$catName];
|
|
|
+ $classId = $classInfo['id'] ?? 0;
|
|
|
+ if (empty($classId)) {
|
|
|
+ echo $catName . ' 这个没有分类id';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+
|
|
|
+ $post = [];
|
|
|
+ $post['sjId'] = $sjId;
|
|
|
+ $post['adminId'] = $adminId;
|
|
|
+ $post['mainId'] = $mainId;
|
|
|
+ $post['staffId'] = $staffId;
|
|
|
+ $post['staffName'] = $staffName;
|
|
|
+ $post['cgStaffId'] = $staffId;
|
|
|
+ $post['cgStaffName'] = $staffName;
|
|
|
+ $post['adminId'] = $adminId;
|
|
|
+
|
|
|
+ $post['name'] = $name;
|
|
|
+ $post['py'] = stringUtil::py($name);
|
|
|
+ $post['stock'] = 0;
|
|
|
+ $post['ratio'] = $ratio;
|
|
|
+ $post['bigUnitId'] = 1;
|
|
|
+ $post['smallUnitId'] = 2;
|
|
|
+
|
|
|
+ $post['classId'] = $classId;
|
|
|
+ $post['className'] = $catName;
|
|
|
+ $post['cover'] = $cover;
|
|
|
+ $post['inTurn'] = $order;
|
|
|
+
|
|
|
+ $post['price'] = 39;
|
|
|
+ $post['skPrice'] = 39;
|
|
|
+ $post['hjPrice'] = 39;
|
|
|
+
|
|
|
+ $post['skMore'] = 6;
|
|
|
+ $post['addPrice'] = 3;
|
|
|
+ $post['hjAddPrice'] = 2;
|
|
|
+
|
|
|
+ $post['hjDiscountPrice'] = 0;
|
|
|
+ $post['discountPrice'] = 0;
|
|
|
+ $post['skDiscountPrice'] = 0;
|
|
|
+
|
|
|
+ $post['cost'] = 0;
|
|
|
+ $post['weight'] = 1.5;
|
|
|
+ $post['stockWarning'] = 5;
|
|
|
+ $post['status'] = 2;
|
|
|
+ $post['itemId'] = 0;
|
|
|
+ $post['smallRatio'] = 1;
|
|
|
+ $post['ratioType'] = 0;
|
|
|
+ $post['appVersion'] = 1;
|
|
|
+
|
|
|
+ ProductClass::addProduct($post, $shop);
|
|
|
+
|
|
|
}
|
|
|
- $name = $ls[0] ?? '';
|
|
|
- $ratio = $ls[3] ?? 20;
|
|
|
- $catName = $ls[4] ?? '';
|
|
|
- $order = $ls[5] ?? 100;
|
|
|
- echo $name.' '.$ratio.' '.$catName.' '.$order;die;
|
|
|
+ echo 'ok';
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ echo $msg;
|
|
|
}
|
|
|
|
|
|
}
|