| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace console\controllers;
- use bizGhs\order\classes\OrderItemClass;
- use yii\console\Controller;
- /**
- * 订单相关
- */
- class OrderItemController extends Controller
- {
- public function actionCost()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $list = OrderItemClass::getAllByCondition(['id<' => 333152, 'xhUnitType' => 1], 'id DESC', '*', null, true);
- if (!empty($list)) {
- foreach ($list as $key => $item) {
- $cost = $item->cost ?? 0;
- $xhPrice = $item->xhPrice ?? 0;
- $ratio = $item->ratio ?? 21;
- $productId = $item->productId ?? 0;
- $name = $item->name ?? '';
- $smallCost = bcdiv($cost, $ratio, 2);
- if ($ratio > 1) {
- if ($cost > 10 && $cost > $xhPrice) {
- // echo $productId . ' ' . $name . ' 成本:' . $cost . ' 价格:' . $xhPrice . ' 比例:' . $ratio . ' 小单位成本:' . $smallCost . "\n";
- // $item->cost = $smallCost;
- // $item->save();
- }
- if ($cost < 10 && $cost > $xhPrice) {
- echo $productId . ' ' . $name . ' 成本:' . $cost . ' 价格:' . $xhPrice . ' 比例:' . $ratio . "\n";
- $item->cost = $xhPrice;
- $item->save();
- }
- }
- }
- }
- }
- }
|