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.
124 lines
4.4 KiB
124 lines
4.4 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\wap\controller;
|
|
|
|
use app\kefu\model\KefuFeedBackModel;
|
|
use app\kefu\services\KefuChatService;
|
|
use app\wap\model\article\Article as ArticleModel;
|
|
use app\wap\model\wap\ArticleCategory;
|
|
use app\wap\model\wap\Search;
|
|
use app\kefu\model\KefuModel;
|
|
use basic\WapBasic;
|
|
use service\JsonService;
|
|
use service\UtilService;
|
|
use think\Db;
|
|
use think\Url;
|
|
use service\GroupDataService;
|
|
use app\wap\model\store\StoreProduct;
|
|
use app\wap\model\store\StoreOrder;
|
|
use app\wap\model\store\StoreOrderCartInfo;
|
|
use app\wap\model\special\Special as SpecialModel;
|
|
use app\wap\model\special\SpecialTask;
|
|
use app\wap\model\material\DataDownload;
|
|
|
|
class Kefu extends AuthController
|
|
{
|
|
const CUSTOMER_DETAIL_GOOD = 1;
|
|
const CUSTOMER_DETAIL_ORDER = 2;
|
|
|
|
const CUSTOMER_SUPPORT_STORE_GOOD = 2;
|
|
const CUSTOMER_SUPPORT_SPECIAL = 1;
|
|
const CUSTOMER_SUPPORT_DATA = 5;
|
|
const CUSTOMER_SUPPORT_SOURCE = 8;
|
|
|
|
const CUSTOMER_SUPPORT_STORE_GOOD_ORDER = 2;
|
|
|
|
public function get_order_info($support_type = 0, $type = 0, $id = 0)
|
|
{
|
|
if (!$id) return JsonService::fail("缺少ID参数!");
|
|
|
|
if ($type == self::CUSTOMER_SUPPORT_STORE_GOOD_ORDER) {
|
|
$storeOrderModel = (new StoreOrder);
|
|
$storeOrderInfoModel = (new StoreOrderCartInfo);
|
|
$info = $storeOrderModel->field('id, order_id, add_time')->find($id);
|
|
if (!$info) return JsonService::fail("订单不存在!");
|
|
|
|
$orderCartInfo = $storeOrderInfoModel
|
|
->where('oid', $id)
|
|
->select()
|
|
->toArray();
|
|
|
|
$info->cartInfo = array_column($orderCartInfo, "cart_info");
|
|
}
|
|
|
|
if (!$info) return JsonService::fail("查询不到相关信息!");
|
|
|
|
$info = $info->toArray();
|
|
|
|
$info['add_time'] = date("Y/m/d H:i:s", $info['add_time']);
|
|
|
|
return JsonService::successful($info);
|
|
}
|
|
|
|
public function get_product_info($support_type = 0, $type = 0, $id = 0)
|
|
{
|
|
if (!$id) return JsonService::fail("缺少ID参数!");
|
|
|
|
if ($type == self::CUSTOMER_SUPPORT_STORE_GOOD) {
|
|
// 商城商品
|
|
$info = (new StoreProduct)->field('id, image, store_name, price, ot_price')->find($id);
|
|
} else if ($type == self::CUSTOMER_SUPPORT_SPECIAL) {
|
|
// 专题商品
|
|
$info = (new SpecialModel)->field('id, image, title as store_name, money as price')->find($id);
|
|
} else if ($type == self::CUSTOMER_SUPPORT_DATA) {
|
|
// 资料
|
|
$info = (new DataDownload)->field('id, image, title as store_name, money as price')->find($id);
|
|
} else if ($type == self::CUSTOMER_SUPPORT_SOURCE) {
|
|
// 素材类型
|
|
$info = (new SpecialTask)->field('id, image, title as store_name')->find($id);
|
|
}
|
|
|
|
if (!$info) return JsonService::fail("查询不到相关信息!");
|
|
|
|
return JsonService::successful($info);
|
|
}
|
|
|
|
public function get_support_info($uidTo = 0, $limit = 10, $toUid = 0 ,$mer_id = 0)
|
|
{
|
|
$uid = $this->uid;
|
|
if($mer_id){
|
|
$mer_id = KefuModel::where('mer_id',$mer_id)->value('id') ?? 0;
|
|
}
|
|
try {
|
|
$result = (new KefuChatService)->getUserSupportInfo($uidTo, $limit, $toUid, $uid,$mer_id);
|
|
} catch (\Exception $e) {
|
|
return JsonService::fail($e->getMessage());
|
|
}
|
|
|
|
|
|
return JsonService::successful($result);
|
|
}
|
|
|
|
public function save_feedback($real_name, $phone, $content,$mer_id)
|
|
{
|
|
KefuFeedBackModel::create([
|
|
'uid' => $this->uid,
|
|
'real_name' => $real_name,
|
|
'phone' => $phone,
|
|
'content' => $content,
|
|
'add_time' => time(),
|
|
'mer_id' => $mer_id
|
|
]);
|
|
|
|
return JsonService::successful("保存成功!");
|
|
}
|
|
}
|
|
|