123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\models\store;
- use app\models\user\User;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- class StoreServiceLog extends BaseModel
- {
-
- protected $pk = 'id';
-
- protected $name = 'store_service_log';
-
- const MSN_TYPE = [1, 2, 3, 4, 5, 6];
-
- const MSN_TYPE_GOODS = 5;
-
- const MSN_TYPE_ORDER = 6;
- use ModelTrait;
-
- public static function lst($uid, $toUid, $page, $limit)
- {
- if (!$limit || !$page) return [];
- $model = new self;
- $model = $model->whereIn('uid', [$uid, $toUid]);
- $model = $model->whereIn('to_uid', [$uid, $toUid]);
- $model = $model->order('id DESC');
- $model = $model->page($page, $limit);
- return $model->select()->each(function ($item) {
- $userInfo = User::getUserInfo($item['uid'], 'nickname,avatar');
- $item['nickname'] = $userInfo['nickname'];
- $item['avatar'] = $userInfo['avatar'];
- if ($item['msn_type'] == self::MSN_TYPE_GOODS && $item['msn']) {
- $item['productInfo'] = StoreProduct::validWhere()->where('id', $item['msn'])->find();
- } else {
- $item['productInfo'] = [];
- }
- $item['orderInfo'] = [];
- if ($item['msn_type'] == self::MSN_TYPE_ORDER && $item['msn']) {
- $order = StoreOrder::getUserOrderDetail($item['uid'], $item['msn']);
- if ($order) {
- $order = StoreOrder::tidyOrder($order->toArray(), true, true);
- $order['add_time_y'] = date('Y-m-d', $order['add_time']);
- $order['add_time_h'] = date('H:i:s', $order['add_time']);
- $item['orderInfo'] = $order;
- }
- }
- });
- }
- }
|