You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.2 KiB
54 lines
2.2 KiB
9 months ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
namespace app\merchant\model\wechat;
|
||
|
|
||
|
use app\merchant\model\wechat\StoreService as ServiceModel;
|
||
|
use app\wap\model\user\User;
|
||
|
use traits\ModelTrait;
|
||
|
use basic\ModelBasic;
|
||
|
|
||
|
/**
|
||
|
* 客服管理 model
|
||
|
* Class StoreServiceLog
|
||
|
* @package app\merchant\model\wechat
|
||
|
*/
|
||
|
class StoreServiceLog extends ModelBasic
|
||
|
{
|
||
|
use ModelTrait;
|
||
|
|
||
|
public static function setWhere($uid, $to_uid, $mer_id)
|
||
|
{
|
||
|
$model = new self;
|
||
|
$where = "mer_id = " . $mer_id . " AND ((uid = " . $uid . " AND to_uid = " . $to_uid . ") OR (uid = " . $to_uid . " AND to_uid = " . $uid . "))";
|
||
|
$model = $model->where($where)->order("add_time desc");
|
||
|
return $model;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array
|
||
|
*/
|
||
|
public static function getChatList($uid, $to_uid, $mer_id, $page, $limit)
|
||
|
{
|
||
|
$data = self::setWhere($uid, $to_uid, $mer_id)->page($page, $limit)->select();
|
||
|
$data = count($data) > 0 ? $data->toArray() : [];
|
||
|
foreach ($data as $key => &$item) {
|
||
|
$user = StoreService::field("nickname,avatar")->where('mer_id', $mer_id)->where(array("uid" => $item["uid"]))->find();
|
||
|
if (!$user) $user = User::field("nickname,avatar")->where(array("uid" => $item["uid"]))->find();
|
||
|
$item["nickname"] = $user["nickname"];
|
||
|
$item["avatar"] = $user["avatar"];
|
||
|
$item["add_time"] = date('Y-m-d H:i:s',$item["add_time"]);
|
||
|
}
|
||
|
$count = self::setWhere($uid, $to_uid, $mer_id)->count();
|
||
|
return compact('data', 'count');
|
||
|
}
|
||
|
}
|