|
|
@@ -2,9 +2,12 @@
|
|
|
|
|
|
namespace bizHd\order\classes;
|
|
|
|
|
|
+use biz\sj\services\MerchantService;
|
|
|
use biz\stat\classes\StatItemClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\stock\classes\StockRecordClass;
|
|
|
+use bizHd\custom\classes\CustomClass;
|
|
|
+use bizHd\order\services\OrderGoodsService;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
use Yii;
|
|
|
@@ -15,6 +18,79 @@ class OrderItemClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizHd\order\models\OrderItem';
|
|
|
|
|
|
+ public static function getOrderInfoList($where)
|
|
|
+ {
|
|
|
+ $respond = self::getList('orderSn,id', $where, 'id DESC');
|
|
|
+ if (!empty($respond['list'])) {
|
|
|
+ $currentList = $respond['list'];
|
|
|
+ $snList = array_column($currentList, 'orderSn');
|
|
|
+ $snList = array_unique(array_filter($snList));
|
|
|
+
|
|
|
+ $order = 'addTime DESC';
|
|
|
+ $where = ['orderSn' => ['in', $snList]];
|
|
|
+ $data = OrderClass::getList('*', $where, $order);
|
|
|
+
|
|
|
+ $myInfoList = [];
|
|
|
+ if (!empty($data['list'])) {
|
|
|
+
|
|
|
+ //获取订单的商品信息
|
|
|
+ $goodsList = OrderGoodsService::getGoodsListByOrderSns($snList);
|
|
|
+
|
|
|
+ //获取订花人的用户信息
|
|
|
+ $orderUserIds = array_column($data['list'], 'customId');
|
|
|
+ $orderUserIds = array_unique(array_filter($orderUserIds));
|
|
|
+ $customList = CustomClass::getCustomByIds($orderUserIds);
|
|
|
+
|
|
|
+ $sjIdList = array_column($data['list'], 'sjId');
|
|
|
+ $sjIdList = array_filter(array_unique($sjIdList));
|
|
|
+ $merchantList = MerchantService::getByIds($sjIdList, null, 'id');
|
|
|
+
|
|
|
+ $periodData = [0 => '上午', 1 => '下午', 2 => '晚上'];
|
|
|
+ $defaultImg = imgUtil::groupImg('');
|
|
|
+ foreach ($data['list'] as $key => $val) {
|
|
|
+ $id = $val['id'];
|
|
|
+ $customId = $val['customId'];
|
|
|
+ $currentActPrice = $val['actPrice'] ?? 0;
|
|
|
+ $currentSendCost = $val['sendCost'] ?? 0;
|
|
|
+ $currentPrice = bcsub($currentActPrice, $currentSendCost, 2);
|
|
|
+ //没有商品显示的样式
|
|
|
+ $goodsInfoList = [['title' => '', 'coverUrl' => $defaultImg, 'unitPrice' => $currentPrice, 'num' => 1]];
|
|
|
+ if (isset($goodsList[$id])) {
|
|
|
+ $goodsInfoList = $goodsList[$id];
|
|
|
+ }
|
|
|
+ $data['list'][$key]['goodsInfoList'] = $goodsInfoList;
|
|
|
+ $data['list'][$key]['bookAvatar'] = isset($customList[$customId]['smallAvatarUrl']) ? $customList[$customId]['smallAvatarUrl'] : '';
|
|
|
+ $sjId = $val['sjId'];
|
|
|
+ $data['list'][$key]['name'] = isset($merchantList[$sjId]['name']) ? $merchantList[$sjId]['name'] : '';
|
|
|
+ $data['list'][$key]['reachTime'] = OrderClass::getReachTime($val);
|
|
|
+ $requireReachTime = '';
|
|
|
+ if ($val['reachDate'] != '0000-00-00') {
|
|
|
+ $reachPeriodId = $val['reachPeriod'];
|
|
|
+ $reachPeriod = isset($periodData[$reachPeriodId]) ? $periodData[$reachPeriodId] : '上午';
|
|
|
+ $requireReachTime = date("m-d", strtotime($val['reachDate'])) . ' ' . $reachPeriod;
|
|
|
+ }
|
|
|
+ $data['list'][$key]['requireReachTime'] = $requireReachTime;
|
|
|
+ $shortCover = $val['cover'] ?? '';
|
|
|
+ $data['list'][$key]['cover'] = imgUtil::groupImg($shortCover);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($data['list'] as $key => $val) {
|
|
|
+ $orderSn = $val['orderSn'];
|
|
|
+ $myInfoList[$orderSn] = $val;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($respond['list'] as $key => $val) {
|
|
|
+ $orderSn = $val['orderSn'] ?? '';
|
|
|
+ $currentInfo = $myInfoList[$orderSn]??[];
|
|
|
+ $respond['list'][$key]['orderInfo'] = $currentInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return $respond;
|
|
|
+ }
|
|
|
+
|
|
|
//添加记录
|
|
|
public static function addData($data, $custom)
|
|
|
{
|