GhsInitController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. }
  40. }
  41. $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  42. if (!empty($customList)) {
  43. foreach ($customList as $custom) {
  44. $ownShopId = $custom->ownShopId ?? 0;
  45. if (isset($shopList[$ownShopId]) == false) {
  46. echo "没有找到客户门店\n";
  47. continue;
  48. }
  49. $shop = $shopList[$ownShopId];
  50. $ptStyle = $shop['ptStyle'] ?? 0;
  51. if (empty($ptStyle)) {
  52. echo "没有找到ptStyle \n";
  53. continue;
  54. }
  55. $custom->ownPtStyle = $ptStyle;
  56. $custom->save();
  57. }
  58. }
  59. }
  60. //清空某个商户的product
  61. public function actionClearItem($sjId)
  62. {
  63. }
  64. public function actionPtUnit()
  65. {
  66. $res = ProductClass::getAllList("*", "");
  67. foreach ($res as $v) {
  68. $id = $v['id'];
  69. $obigU = $v['bigUnit'];
  70. $oSmallU = $v['smallUnit'];
  71. $bigUname = xhItemService::getUnitName($obigU);
  72. $smallUName = xhItemService::getUnitName($oSmallU);
  73. $data = [
  74. 'bigUnitId' => $obigU,
  75. 'smallUnitId' => $oSmallU,
  76. 'bigUnit' => $bigUname,
  77. 'smallUnit' => $smallUName,
  78. ];
  79. ProductClass::updateById($id, $data);
  80. }
  81. echo "done";
  82. }
  83. }