| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * User: admin
- * Date Time: 2021/4/7 21:29
- */
- namespace console\controllers;
- use biz\item\classes\PtItemClass;
- use biz\shop\classes\ShopClass;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\ghs\classes\GhsClass;
- use bizGhs\item\classes\ItemClass;
- use bizGhs\item\classes\ItemClassClass;
- use bizGhs\product\classes\ProductClass;
- use common\services\xhItemService;
- use yii\console\Controller;
- class GhsInitController extends Controller
- {
- public function actionChangePtStyle()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $shopList = ShopClass::getAllByCondition(['id>' => 0], null, '*', 'id');
- $ghsList = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
- if (!empty($ghsList)) {
- foreach ($ghsList as $ghs) {
- $ownShopId = $ghs->ownShopId ?? 0;
- if (isset($shopList[$ownShopId]) == false) {
- echo "没有找到供货商门店\n";
- continue;
- }
- $shop = $shopList[$ownShopId];
- $ptStyle = $shop['ptStyle'] ?? 0;
- if (empty($ptStyle)) {
- echo "没有找到ptStyle \n";
- continue;
- }
- $ghs->ownPtStyle = $ptStyle;
- $ghs->save();
- echo "ok \n";
- }
- }
- $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
- if (!empty($customList)) {
- foreach ($customList as $custom) {
- $ownShopId = $custom->ownShopId ?? 0;
- if (isset($shopList[$ownShopId]) == false) {
- echo "没有找到客户门店\n";
- continue;
- }
- $shop = $shopList[$ownShopId];
- $ptStyle = $shop['ptStyle'] ?? 0;
- if (empty($ptStyle)) {
- echo "没有找到ptStyle \n";
- continue;
- }
- $custom->ownPtStyle = $ptStyle;
- $custom->save();
- echo "ok \n";
- }
- }
- }
- //清空某个商户的product
- public function actionClearItem($sjId)
- {
- }
- public function actionPtUnit()
- {
- $res = ProductClass::getAllList("*", "");
- foreach ($res as $v) {
- $id = $v['id'];
- $obigU = $v['bigUnit'];
- $oSmallU = $v['smallUnit'];
- $bigUname = xhItemService::getUnitName($obigU);
- $smallUName = xhItemService::getUnitName($oSmallU);
- $data = [
- 'bigUnitId' => $obigU,
- 'smallUnitId' => $oSmallU,
- 'bigUnit' => $bigUname,
- 'smallUnit' => $smallUName,
- ];
- ProductClass::updateById($id, $data);
- }
- echo "done";
- }
- }
|