GhsInitController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * User: admin
  4. * Date Time: 2021/4/7 21:29
  5. */
  6. namespace console\controllers;
  7. use biz\item\classes\PtItemClass;
  8. use biz\shop\classes\ShopClass;
  9. use bizGhs\custom\classes\CustomClass;
  10. use bizGhs\ghs\classes\GhsClass;
  11. use bizGhs\item\classes\ItemClass;
  12. use bizGhs\item\classes\ItemClassClass;
  13. use bizGhs\product\classes\ProductClass;
  14. use common\services\xhItemService;
  15. use yii\console\Controller;
  16. class GhsInitController extends Controller
  17. {
  18. public function actionChangePtStyle()
  19. {
  20. ini_set('memory_limit', '2045M');
  21. set_time_limit(0);
  22. $shopList = ShopClass::getAllByCondition(['id>' => 0], null, '*', 'id');
  23. $ghsList = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  24. if (!empty($ghsList)) {
  25. foreach ($ghsList as $ghs) {
  26. $ownShopId = $ghs->ownShopId ?? 0;
  27. if (isset($shopList[$ownShopId]) == false) {
  28. echo "没有找到供货商门店\n";
  29. continue;
  30. }
  31. $shop = $shopList[$ownShopId];
  32. $ptStyle = $shop['ptStyle'] ?? 0;
  33. if (empty($ptStyle)) {
  34. echo "没有找到ptStyle \n";
  35. continue;
  36. }
  37. $ghs->ownPtStyle = $ptStyle;
  38. $ghs->save();
  39. echo "ok \n";
  40. }
  41. }
  42. $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  43. if (!empty($customList)) {
  44. foreach ($customList as $custom) {
  45. $ownShopId = $custom->ownShopId ?? 0;
  46. if (isset($shopList[$ownShopId]) == false) {
  47. echo "没有找到客户门店\n";
  48. continue;
  49. }
  50. $shop = $shopList[$ownShopId];
  51. $ptStyle = $shop['ptStyle'] ?? 0;
  52. if (empty($ptStyle)) {
  53. echo "没有找到ptStyle \n";
  54. continue;
  55. }
  56. $custom->ownPtStyle = $ptStyle;
  57. $custom->save();
  58. echo "ok \n";
  59. }
  60. }
  61. }
  62. //清空某个商户的product
  63. public function actionClearItem($sjId)
  64. {
  65. }
  66. public function actionPtUnit()
  67. {
  68. $res = ProductClass::getAllList("*", "");
  69. foreach ($res as $v) {
  70. $id = $v['id'];
  71. $obigU = $v['bigUnit'];
  72. $oSmallU = $v['smallUnit'];
  73. $bigUname = xhItemService::getUnitName($obigU);
  74. $smallUName = xhItemService::getUnitName($oSmallU);
  75. $data = [
  76. 'bigUnitId' => $obigU,
  77. 'smallUnitId' => $oSmallU,
  78. 'bigUnit' => $bigUname,
  79. 'smallUnit' => $smallUName,
  80. ];
  81. ProductClass::updateById($id, $data);
  82. }
  83. echo "done";
  84. }
  85. }