OrderItemController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace console\controllers;
  3. use bizGhs\order\classes\OrderItemClass;
  4. use yii\console\Controller;
  5. /**
  6. * 订单相关
  7. */
  8. class OrderItemController extends Controller
  9. {
  10. public function actionCost()
  11. {
  12. ini_set('memory_limit', '2045M');
  13. set_time_limit(0);
  14. $list = OrderItemClass::getAllByCondition(['id<' => 333152, 'xhUnitType' => 1], 'id DESC', '*', null, true);
  15. if (!empty($list)) {
  16. foreach ($list as $key => $item) {
  17. $cost = $item->cost ?? 0;
  18. $xhPrice = $item->xhPrice ?? 0;
  19. $ratio = $item->ratio ?? 21;
  20. $productId = $item->productId ?? 0;
  21. $name = $item->name ?? '';
  22. $smallCost = bcdiv($cost, $ratio, 2);
  23. if ($cost > 10 && $cost > $xhPrice) {
  24. echo $productId . ' ' . $name . ' 成本:' . $cost . ' 价格:' . $xhPrice . ' 比例:' . $ratio . ' 小单位成本:' . $smallCost . "\n";
  25. $item->cost = $smallCost;
  26. $item->save();
  27. }
  28. if ($cost < 10 && $cost > $xhPrice) {
  29. //echo $productId . ' ' . $name . ' 成本:' . $cost . ' 价格:' . $xhPrice . ' 比例:' . $ratio . "\n";
  30. }
  31. }
  32. }
  33. }
  34. }