| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace bizGhs\order\classes;
- use bizGhs\order\models\RefundOrderItem;
- use Yii;
- use bizGhs\base\classes\BaseClass;
- class RefundOrderItemClass extends BaseClass
- {
- public static $baseFile = '\bizGhs\order\models\RefundOrderItem';
- public static function getRefundItemList($where)
- {
- $data = self::getList('*', $where, 'id DESC');
- $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
- if (empty($list)) {
- return $data;
- }
- $orderSnList = array_column($list, 'orderSn');
- $infoList = RefundOrderClass::getAllByCondition(['orderSn' => ['in', $orderSnList]], null, '*', 'orderSn');
- foreach ($list as $key => $val) {
- $orderSn = $val['orderSn'] ?? '';
- $info = $infoList[$orderSn] ?? [];
- $list[$key]['refundInfo'] = $info;
- }
- $data['list'] = $list;
- $where2 = $where;
- if (isset($where2['productId'])) {
- $newIds = $where2['productId'][1];
- unset($where2['productId']);
- $where2['productId'] = $newIds;
- }
- if (isset($where2['addTime'])) {
- $start = $where2['addTime'][1][0];
- $end = $where2['addTime'][1][1];
- unset($where2['addTime']);
- $totalAmount = RefundOrderItem::find()->where($where2)->andWhere(['between', 'addTime', $start, $end])->sum('xhPrice');
- $totalCost = RefundOrderItem::find()->where($where2)->andWhere(['between', 'addTime', $start, $end])->sum('itemCost*xhNum');
- } else {
- $totalAmount = RefundOrderItem::find()->where($where2)->sum('xhPrice');
- $totalCost = RefundOrderItem::find()->where($where2)->sum('itemCost*xhNum');
- }
- $data['totalAmount'] = $totalAmount;
- $data['totalCost'] = $totalCost;
- return $data;
- }
- public static function addData($data, $order)
- {
- self::add($data);
- }
- public static function batchAddOrderItem($data)
- {
- self::batchAdd($data);
- }
- public static function getOrderItemDetail($orderSn)
- {
- return self::getAllByCondition(['orderSn' => $orderSn], null, '*');
- }
- }
|