初始化

master
wangxinglong 2021-11-19 19:06:22 +08:00
parent 82f5a8f3f5
commit ef39ca8a3f
18 changed files with 595 additions and 756 deletions

View File

@ -1,35 +0,0 @@
<?php
namespace app\controller;
use app\repository\OperationRepository;
use Exception;
use think\response\View;
use think\response\Redirect;
use app\repository\CmsRepository;
use app\repository\BlockRepository;
use think\db\exception\DbException;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
class About extends Base
{
/**
* 列表页
*
* @return Redirect|View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws Exception
*/
public function index()
{
$this->setSeo();
$about = CmsRepository::getInstance()->getAbout($this->aboutCategory['id']);
$this->data['about'] = $about;
$this->data['category'] = $this->aboutCategory;
return $this->view();
}
}

View File

@ -1,513 +0,0 @@
<?php
namespace app\controller;
use app\exception\RepositoryException;
use app\repository\AccountRepository;
use app\repository\CommonRepository;
use app\repository\GoodsRepository;
use app\service\Kd100;
use app\validate\Account as VAccount;
use app\repository\OrderRepository;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\response\Json;
use think\response\View;
class Account extends Base
{
protected $middleware = ['login'];
/**
* 个人中心
*
* @return View
* @throws DbException
*/
public function index(): View
{
$this->data['countList'] = OrderRepository::getInstance()->findOrderCount($this->authId);
$this->data['markList'] = OrderRepository::getInstance()->auctionMarkList('', [$this->authId]);
$this->data['biddingList'] = GoodsRepository::getInstance()->auctionBiddingList($this->authId);
return $this->view();
}
/**
* 个人资料
*
* @return View|Json
* @throws RepositoryException
*/
public function profile()
{
$repo = AccountRepository::getInstance();
$item = $repo->findById($this->authId);
if ($this->request->isPost()) {
$post = input('post.');
$update = [];
$update['headimgurl'] = $post['headimgurl'] ?? '';
$update['sex'] = $post['sex'];
$update['nickname'] = $post['nickname'];
if (!empty($post['nickname']) && $item['nickname'] !== $post['nickname']) {
if ($item['nickname_time'] > 0) {
return $this->json(4001, '每人仅先修改一次昵称,您已修改过了。');
}
$update['nickname_time'] = $item['nickname_time'] + 1;
}
$item->save($update);
return $this->json();
}
$this->data['item'] = $item;
return $this->view();
}
/**
* 我的订单
*
* @return View
*/
public function order(): View
{
$accountId = $this->auth['id'] ?? 0;
$tag = input('get.tag/s', 'waiting');
$this->data['items'] = OrderRepository::getInstance()->getOrderGoods($accountId, $tag);
$this->data['tag'] = $tag;
return $this->view();
}
/**
* 保证金
*
* @return View
* @throws RepositoryException
*/
public function deposit(): View
{
$accountId = $this->auth['id'] ?? 0;
if (!$accountId) {
$this->error('请先登录');
}
$item = AccountRepository::getInstance()->findById($accountId, ['quota', 'id', 'deposit']);
$this->data['item'] = $item;
return $this->view();
}
/**
* 实名认证
*
* @return View|Json
* @throws RepositoryException
*/
public function realName()
{
$accountId = $this->auth['id'] ?? 0;
$account = AccountRepository::getInstance()->findById($accountId);
if ($this->request->isPost()) {
if (!$account) {
return $this->json(4001, '请先登录');
}
if ($account['is_real_name']) {
return $this->json(4002, '您已通过认证');
}
$post = input('post.');
$validate = new VAccount();
if (!$validate->scene('real_name')->check($post)) {
return $this->json(4003, $validate->getError());
}
$post['is_real_name'] = 1;
$account->save($post);
return $this->json();
}
$this->data['item'] = $account;
return $this->view();
}
/**
* 个人账户
*
* @return View
* @throws RepositoryException
*/
public function info(): View
{
$accountId = $this->auth['id'] ?? 0;
$item = AccountRepository::getInstance()->findById($accountId);
$rechargeList = AccountRepository::getInstance()->fetchRechargeList($accountId);
$withdrawalList = AccountRepository::getInstance()->fetchWithdrawalList($accountId);
$this->data['item'] = $item;
$this->data['rechargeList'] = $rechargeList['list'];
$this->data['withdrawalList'] = $withdrawalList['list'];
return $this->view();
}
/**
* 中标清单
*
* @return View
* @throws DbException
*/
public function biddingList(): View
{
$accountId = $this->auth['id'] ?? 0;
$pageParams['query'] = input('get.');
$list = OrderRepository::getInstance()->auctionMarkList('', [$accountId], $pageParams);
$this->data['list'] = $list;
return $this->view();
}
/**
* 竞价清单
*
* @return View
*/
public function biddingLog(): View
{
$list = GoodsRepository::getInstance()->auctionBiddingList($this->authId);
$this->data['items'] = $list;
return $this->view();
}
/**
* 关注的拍品
*
* @return View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function auctionCollection(): View
{
$accountId = $this->auth['id'] ?? 0;
$items = AccountRepository::getInstance()->fetchCollection($accountId, GoodsRepository::TYPE_AUCTION);
$this->data['items'] = $items;
return $this->view();
}
/**
* 商品收藏
*
* @return View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function goodsCollection(): View
{
$accountId = $this->auth['id'] ?? 0;
$items = AccountRepository::getInstance()->fetchCollection($accountId, GoodsRepository::TYPE_GOODS);
$this->data['items'] = $items;
return $this->view();
}
/**
* 地址管理
*
* @return View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function address(): View
{
$accountId = $this->auth['id'] ?? 0;
//地址列表
$addressList = AccountRepository::getInstance()->findAddressByUid($accountId);
$this->data['addressList'] = $addressList;
return $this->view();
}
/**
* 地址详情
*
* @return Json|View
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function addressDetail()
{
$resp = AccountRepository::getInstance();
$accountId = $this->auth['id'] ?? 0;
$id = input('param.id/d', 0);
$item = $resp->findAddressById($id);
if ($this->request->isPost()) {
$postItem = input('post.');
$postItem['user_id'] = $postItem['user_id'] ?? $accountId;
$resp->saveAddress($postItem);
return $this->json();
}
$this->data['item'] = $item;
return $this->view();
}
/**
* 地址删除
*
* @return Json
*/
public function addressDel(): Json
{
if ($this->request->isPost()) {
$id = input('post.id/d', 0);
AccountRepository::getInstance()->delAddress($id);
return $this->json();
}
return $this->json(4002, '请求方式错误');
}
/**
* 修改密码
*
* @return Json
*/
public function editPwd(): Json
{
$post = input('post.');
$accountId = $this->auth['id'] ?? 0;
$validate = new VAccount();
if (!$validate->scene('edit_password')->check($post)) {
return $this->json(4002, $validate->getError());
}
try {
AccountRepository::getInstance()->modifyPwd($accountId, $post['old_password'], $post['password']);
} catch (Exception $e) {
$this->json(4003, $e->getMessage());
}
return $this->json();
}
/**
* 取消收藏|关注
*
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function unCollect(): Json
{
$accountId = $this->auth['id'] ?? 0;
$goodsId = input('post.id/d');
AccountRepository::getInstance()->unCollectGoods($accountId, $goodsId);
return $this->json();
}
/**
* 操作保证金 充值|退回 相应改变额度
*
* @return Json
* @throws RepositoryException
*/
public function operateDeposit(): Json
{
if ($this->request->isPost()) {
$accountId = $this->auth['id'] ?? 0;
$amount = input('post.value', 0);
$type = input('post.type/s', 'recharge');
if (!AccountRepository::getInstance()->isEnough($accountId, $amount, 'deposit')) {
return $this->json(4000, '余额不足');
}
try {
AccountRepository::getInstance()->operateDeposit($accountId, $amount, $type);
} catch (RepositoryException $e) {
return $this->json(4002, $e->getMessage());
} catch (Exception $e) {
CommonRepository::log('保证金充值失败', $e);
return $this->json(5001, '充值失败');
}
return $this->json();
}
return $this->json(4002, '请求方式错误');
}
/**
* 充值
*
* @return Json
* @throws GuzzleException
*/
public function rechargeAmount(): Json
{
if ($this->request->isPost()) {
$accountId = $this->auth['id'] ?? 0;
$amount = input('post.amount', 0);
$type = input('post.type/s');
if (!$accountId) {
return $this->json(4001, '请先登录');
}
try {
$qr = AccountRepository::getInstance()->recharge($accountId, (float) $amount, $type);
return $this->json(0, 'success', ['payment_order_number' => $qr['order_id'], 'code_url' => $qr['qr']]);
} catch (Exception $e) {
CommonRepository::log('充值失败', $e);
return $this->json(5001, '充值失败:'.$e->getMessage());
}
}
return $this->json(4002, '请求方式错误');
}
/**
* 重新充值
*
* @return Json
* @throws GuzzleException
*/
public function rechargeAgain(): Json
{
if ($this->request->isPost()) {
$accountId = $this->auth['id'] ?? 0;
$orderId = input('post.order_id', 0);
$type = input('post.type/s');
if (!$accountId) {
return $this->json(4001, '请先登录');
}
try {
$qr = AccountRepository::getInstance()->rechargeAgain($accountId, $orderId, $type);
return $this->json(0, 'success', ['payment_order_number' => $qr['order_id'], 'code_url' => $qr['qr']]);
} catch (Exception $e) {
CommonRepository::log('充值失败', $e);
return $this->json(5001, '充值失败:'.$e->getMessage());
}
}
return $this->json(4002, '请求方式错误');
}
/**
* 查询订单
*
* @return array|Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function checkPayment()
{
if ($this->request->isPost()) {
$res['code'] = 0;
$res['msg'] = 'success';
$res['data']['paid'] = true;
$orderId = input('post.order_id/s', ''); //订单ID
$type = input('post.type/s', 'all'); //支付方式
if (!$orderId || !$type) {
$res['code'] = 1;
$res['msg'] = '参数错误';
return $res;
}
//根据支付类型 请求接口查询订单
$hasPaid = AccountRepository::getInstance()->hasPaid($orderId, $type);
if ($hasPaid) {
AccountRepository::getInstance()->paymentLogPaid($orderId, $type);
}
$res['data']['paid'] = $hasPaid;
return $res;
}
return $this->json(1, '非法请求!');
}
/**
* 提现
*
* @return Json
*/
public function withdrawal(): Json
{
if ($this->request->isPost()) {
$amount = input('post.amount', '');
$accountId = $this->auth['id'] ?? 0;
try {
AccountRepository::getInstance()->withdrawal($accountId, $amount);
return $this->json();
} catch (Exception $e) {
CommonRepository::log('提现失败', $e);
return $this->json(5001, '提现失败');
}
}
return $this->json(1, '非法请求!');
}
/**
* 获取已有订单号的支付二维码
*
* @return Json
* @throws GuzzleException
*/
public function getPaymentQr(): Json
{
if ($this->request->isPost()) {
$type = input('post.type', '');
$orderId = input('post.order_id', '');
try {
$codeQr = OrderRepository::getInstance()->generatePaymentQrCode($type, $orderId);
return $this->json(0, 'success', ['payment_order_number' => $orderId, 'code_url' => $codeQr]);
} catch (Exception $e) {
CommonRepository::log('获取支付二维码', $e);
return $this->json(5001, '获取支付二维码');
}
}
}
/**
* 物流查询
*
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function logistics(): Json
{
$orderId = input('post.order_id');
$type = input('post.type', 'goods');
// $com = 'shunfeng';
// $num = 'SF1980860132707';
if ($type == 'goods') {
if (!$delivery = OrderRepository::getInstance()->findExpressByOrder($orderId)) {
return $this->json(4001, '物流信息不存在');
}
} else {
if (!$delivery = OrderRepository::getInstance()->findExpressByAuction($orderId)) {
return $this->json(4001, '物流信息不存在');
}
}
$com = $delivery['express_code'];
$num = $delivery['express_number'];
return $this->json(0, 'success', ['res' => Kd100::query($com, $num)]);
}
}

View File

@ -1,99 +0,0 @@
<?php
namespace app\controller;
use app\model\{Archives as MArticle, Category};
use think\facade\View;
class Article extends Base
{
//详情
public function detail($id = 0)
{
if ($id <= 0) {
return $this->error('错误页面');
}
$article = MArticle::getById($id);
if (empty($article)) {
return $this->error('无此文章');
}
MArticle::updateById($id, ['views' => $article['views'] + 1]);
$category = Category::getById($article['category_id']);
$prev = MArticle::getPrevArticleByIdAndCategoryId($id, $article['category_id']);
$next = MArticle::getNextArticleByIdAndCategoryId($id, $article['category_id']);
$keywords = $article['seo_keywords'] ?: $this->system['seo_keywords'];
$description = $article['seo_description'] ?: $this->system['seo_description'];
$this->setSeo($article['title'], $keywords, $description);
$this->data['article'] = $article;
$this->data['category'] = $category;
$this->data['categoryId'] = $category['id'];
$this->data['prev'] = $prev;
$this->data['next'] = $next;
return $this->view($category['template_detail'] ?? '');
}
//列表页
public function index()
{
$categoryId = input('category_id/d', 0);
if ($categoryId <= 0) {
return $this->error('错误页面');
}
$category = Category::getById($categoryId);
$page_size = 20;
if( $category['number'])$page_size= $category['number'];
if( $this->request->param("page_size/d")){
$page_size= $this->request->param("page_size/d");
cookie("article_page_size",$this->request->param("page_size/d"));
}else{
if( cookie("?article_page_size"))$page_size= cookie("article_page_size");
}
if (empty($category)) {
return $this->error('错误页面');
}
$description = $category['description'] ?: $this->system['seo_description'];
$this->setSeo($category['title'], $this->system['seo_keywords'], $description);
$this->data['items'] = MArticle::getListPageByCategory($categoryId, $page_size);
$this->data['category'] = $category;
$this->data['categoryId'] = $categoryId;
$this->data['page_size'] = $page_size;
$this->data['article_count'] = MArticle::getListCount($categoryId);
return $this->view($category['template_list'] ?? '');
}
//查询
public function query(): \think\response\View
{
$keyword = $this->request->param("keyword/s");
//无key值跳转到产品
if (!$keyword) $this->redirect((string)url('/articles/12.html'));
$where = [
['category_id', 'in', [5, 12, 13, 14, 15]],
['status', '=', 1],
];
$where[] = ['title', 'like', '%' . $keyword . '%'];
$param['keyword'] = $keyword;
$paginate = [
'list_rows' => 20,
'query' => $param
];
$data = MArticle::where($where)
->order("sort desc")
->paginate($paginate, false);
View::assign("items", $data);
View::assign("keyword", $keyword);
$this->data['category'] = Category::getById(5);
$this->data['categoryId'] = 5;
return $this->view("/article/product_query");
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace app\controller;
use app\repository\BlockRepository;
use Exception;
use think\response\View;
use app\repository\OperationRepository;
class Contact extends Base
{
/**
* @return View
* @throws Exception
*/
public function index(): View
{
$position = ['contact_banner'];
$slides = OperationRepository::getInstance()->slideListByPosition($position);
$this->data['blocks'] = BlockRepository::getInstance()->getByCateName(BlockRepository::CATEGORY_CONTACT);
$this->data['slide'] = $slides;
$this->setSeo();
return $this->view();
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace app\controller;
use app\model\{Category, Block};
class Page extends Base
{
public function index()
{
$categoryId=$this->request->param("category_id");
$category = Category::getById($this->request->param("category_id"));
if ($category) {
$description = $category['description'] ?: $this->system['seo_description'];
$this->setSeo($category['title'], $this->system['seo_keywords'], $description);
} else {
return $this->error('错误页面');
}
$childCategory = Category::getChildrenByParentId($categoryId);
$this->data['categoryId'] = $categoryId;
$this->data['category'] = $category;
$this->data['childCategory'] = $childCategory;
$this->data['blocks'] = Block::getByCategoryId($categoryId);
return $this->view($category['template_detail']);
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace app\controller;
use app\repository\AccountRepository;
use app\repository\GoodsRepository;
use app\repository\OperationRepository;
use Exception;
use think\response\View;
class Search extends Base
{
/**
* 搜索
*
* @return View
* @throws Exception
*/
public function index(): View
{
$tag = input('get.tag/s', 'goods');
$keyword = input('get.keyword/s', '');
$pageParams['query'][] = input('get.');
$where['size'] = 50;
$where['where'][] = ['type', '=', $tag];
$where['where'][] = ['status', '=', GoodsRepository::STATUS_ON];
$where['where'][] = ['stock', '>', 0];
$where['where'][] = ['title', 'like', '%'.$keyword.'%'];
$items = GoodsRepository::getInstance()->findListWithPaginate($where, $pageParams);
$position = ['search_banner'];
$slides = OperationRepository::getInstance()->slideListByPosition($position);
$collectedIds = $this->authId ? AccountRepository::getInstance()->getCollectedIds($this->authId, $tag) : [];
$this->data['items'] = $items;
$this->data['collectedIds'] = $collectedIds;
$this->data['slide'] = $slides;
return $this->view();
}
}

View File

@ -10,7 +10,6 @@ use app\model\Recharge;
use app\model\Business as BusinessModel;
use app\model\Member;
use app\repository\BusinessRepository;
use app\repository\CouponRepository;
use app\repository\RechargeRepository;
use app\service\wx\WechatPay;
use Exception;
@ -23,7 +22,6 @@ use think\response\View;
class Business extends Base
{
protected $noNeedLogin = ['queryManagerRecharge'];
/**
* 商家列表列表
*

View File

@ -0,0 +1,126 @@
<?php
namespace app\controller\manager;
use app\exception\RepositoryException;
use app\model\Account;
use app\model\BusinessFlow;
use app\model\Coupon;
use app\model\CouponMain;
use app\model\Recharge;
use app\model\Business as BusinessModel;
use app\model\Member;
use app\model\Tag;
use app\repository\AccountRepository;
use app\repository\BusinessRepository;
use app\repository\CouponRepository;
use app\repository\RechargeRepository;
use app\service\wx\WechatPay;
use Exception;
use think\facade\Db;
use think\response\Json;
use think\response\View;
/**
* 消费者
**/
class Consumer extends Base
{
/**
* 列表
*
* @return Json|View
* @throws Exception
*/
public function index()
{
$stateArray = Account::allState();
if ($this->request->isPost()) {
$repo = AccountRepository::getInstance();
$keyword = $this->request->param('keyword/s', '');
$state = $this->request->param('state/d', "-1");
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$whereMap = [["type", "=", Account::type_consumer]];
$orders = ['id' => 'desc'];
if (!empty($keyword)) {
$whereMap[] = ['nick_name', 'like', "%$keyword%"];
}
if (isset($stateArray[$state])) {
$whereMap[] = ['state', '=', $state];
}
$list = $repo->findList($whereMap, [], $page, $size, function ($q) {
return $q->with("tag");
}, $orders);
$list["list"]->each(function ($item) {
//优惠券领取总数
$item->coupon_total_count = Coupon::where(["consumer_code" => $item->user_code])->count("id");
//优惠券使用总数
$item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id");
//优惠券未使用总数
$item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id");
});
return $this->json(0, 'success', $list);
}
$this->data["state"] = $stateArray;
return $this->view();
}
/**
* 消费者详情
*
* @return Json|View
* @throws Exception
*/
public function info()
{
$id = input("id/d", 0);
$consumer = Account::findOne(["id" => $id], [], function ($q) {
return $q->with("tag");
});
//只查询优惠券持有
if ($this->request->isPost()) {
$repo = AccountRepository::getInstance();
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
$list = $repo->consumerCouponList($consumer['user_code'], $page, $size);
$time = time();
$list["list"]->each(function ($item) use ($time) {
if(strtotime($item['end_time']) < $time){
$item->time_state = '已过期';
}else{
$item->time_state = '未过期';
}
});
return $this->json(0, 'success', $list);
}
if (empty($consumer)) {
return $this->json(4001, "消费者不存在");
}
$rep = AccountRepository::getInstance();
//评论总数数
$this->data["totalComment"] = $rep->consumerTotalComment($consumer["user_code"]);
//评论总数数
$this->data["totalTheMonthComment"] = $rep->consumerTheMonthTotalComment($consumer["user_code"]);
//优惠券领取总数
$this->data["couponTotalCount"] = $rep->consumerTotalCoupon($consumer["user_code"]);
//优惠券使用总数
$this->data["couponUsedTotalCount"] = $rep->consumerUsedTotalCoupon($consumer["user_code"]);
//优惠券未使用总数
$this->data["couponNotUsedTotalCount"] = $rep->consumerNotUsedTotalCoupon($consumer["user_code"]);
$this->data["consumer"] = $consumer->toArray();
return $this->view();
}
}

View File

@ -8,4 +8,27 @@ use think\exception\ValidateException;
class Account extends Base
{
public const type_consumer = 0;//个人消费者
public const type_business = 1;//商家
public const type_staff = 2;//员工
public const state_default = 0;// 未提交
public const state_examineing = 1 ;// 1审核中
public const state_fail = 2;// 2拒绝
public const state_success = 3;// 3审核通过
public static function allState(){
return [
self::state_default=>"未提交",
self::state_examineing=>"审核中",
self::state_fail=>"拒绝",
self::state_success=>"审核通过",
];
}
public function tag()
{
return $this->hasOne(Tag::class,"id","tag_id");
}
}

10
app/model/Tag.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace app\model;
use Exception;
use think\exception\ValidateException;
class Tag extends Base
{
}

View File

@ -5,6 +5,8 @@ namespace app\repository;
use app\exception\RepositoryException;
use app\service\Repository;
use app\traits\CommentTrait;
use app\traits\CouponTrait;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -19,16 +21,8 @@ use think\Model;
*/
class AccountRepository extends Repository
{
/**
* 获取用户列表
*
* @throws RepositoryException
*/
public function list(): ?array
{
return $this->findList();
}
use CommentTrait;
use CouponTrait;
/**
* 获取指定账户记录By手机号
*

View File

@ -0,0 +1,30 @@
<?php
namespace app\traits;
use think\Model;
use app\model\Comment;
use think\db\exception\DbException;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
trait CommentTrait
{
/**消费者评论总数
* @param string $userCode
*
**/
public function consumerTotalComment($userCode){
return Comment::where("user_code",$userCode)->where("is_delete",Comment::COMMON_OFF)->count("id");
}
/**消费者评论本月总数
* @param string $userCode
*
**/
public function consumerTheMonthTotalComment($userCode){
return Comment::where("user_code",$userCode)
->where("is_delete",Comment::COMMON_OFF)
->whereTime("create_time",">=",date("Y-m-1 00:00:00"))
->count("id");
}
}

View File

@ -0,0 +1,57 @@
<?php
namespace app\traits;
use think\Model;
use app\model\Coupon;
trait CouponTrait
{
/**消费者持有优惠券总数
* @param string $userCode
*
*
* @return int
*/
public function consumerTotalCoupon($userCode)
{
return Coupon::where("consumer_code", $userCode)->count("id");
}
/**消费者已使用优惠券总数
* @param string $userCode
*
*
* @return int
*/
public function consumerUsedTotalCoupon($userCode)
{
return Coupon::where("consumer_code", $userCode)->where("is_verificated", Coupon::is_verificated_on)->count("id");
}
/**消费者已使用优惠券总数
* @param string $userCode
*
*
* @return int
*/
public function consumerNotUsedTotalCoupon($userCode)
{
return Coupon::where("consumer_code", $userCode)->where("is_verificated", Coupon::is_verificated_off)->count("id");
}
/**消费者已使用优惠券总数
* @param string $userCode
*
*
* @return array
* @throws \Exception
*/
public function consumerCouponList($userCode, $page, $size)
{
return Coupon::findList(["consumer_code" => $userCode], [], $page, $size, null, ["id" => "desc"]);
}
}

View File

@ -46,10 +46,10 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
{templet: '#row-cover', title: '头像', style: 'height: 90px;'},
{templet:function(d){
return d.account.nick_name
},field: 'nick_name', title: '昵称'},
}, title: '昵称'},
{templet:function(d){
return d.business.business_name
},field: 'business_name', title: '商家名称'},
return d.business.business_name
} ,title: '商家名称'},
{field: 'coupon_total_count', title: '优惠券总数量'},
{field: 'coupon_doing_count', title: '进行中优惠券数量'},
{field: 'coupon_receive_count', title: '已领取优惠券数量'},

View File

@ -0,0 +1,80 @@
layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
let $ = layui.jquery,
form = layui.form,
table = layui.table,
layer = layui.layer,
xmSelect = layui.xmSelect,
miniTab = layui.miniTab;
/**** index begin ***/
//index页面
if ($('.location-index-page').length > 0) {
miniTab.listen();
// 渲染表格
let listUrl = $('#table-container').data('url');
let insTb = table.render({
elem: '#table-container',
toolbar: '#toolbar-tpl',
defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '搜索'
, layEvent: 'search'
, icon: 'layui-icon-search'
}],
url: listUrl,
method: 'post',
even: true,
limits: [10,20,50,100,200,500,1000],
request: {
pageName: 'page',
limitName: 'size',
},
parseData: function (res) {
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
cols: [[
// {type: 'checkbox'},
{field: 'id' , width: 80, title: 'ID'},
{templet: '#row-cover', title: '头像', style: 'height: 90px;'},
{field: 'nick_name', title: '昵称'},
{field: 'gender', title: '性别'},
{field: 'coupon_total_count', title: '优惠券领取数'},
{field: 'coupon_used_count', title: '优惠券使用数'},
{field: 'coupon_not_use_count', title: '优惠券未使用数'},
{field: 'login_time', title: '最近登录'},
{templet:function(d){
if( d.tag != undefined && d.tag.name != null){
return d.tag.name
}
return '';
},title: '用户标签'},
{templet: '#row-operate', minWidth: 350, field: 'right', align: 'center', title: '操作', fixed: 'right'}
]],
done: function () {
Tools.setInsTb(insTb);
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
//执行搜索重载
table.reload('table-container', {
page: {curr: 1}
, where: data.field
}, 'data');
return false;
});
}
/*** index end ***/
});

View File

@ -0,0 +1,59 @@
layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
let $ = layui.jquery,
form = layui.form,
table = layui.table,
layer = layui.layer,
xmSelect = layui.xmSelect,
miniTab = layui.miniTab;
/**** index begin ***/
//index页面
if ($('.location-index-page').length > 0) {
miniTab.listen();
// 渲染表格
let listUrl = $('#table-container').data('url');
let insTb = table.render({
elem: '#table-container',
toolbar: '#toolbar-tpl',
defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '搜索'
, layEvent: 'search'
, icon: 'layui-icon-search'
}],
url: listUrl,
method: 'post',
even: true,
limits: [10,20,50,100,200,500,1000],
request: {
pageName: 'page',
limitName: 'size',
},
parseData: function (res) {
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
cols: [[
// {type: 'checkbox'},
{field: 'id' , width: 80, title: 'ID'},
{field: 'name', title: '名称'},
{field: 'type_name', title: '优惠券类型'},
{field: 'money', title: '金额'},
{field: 'business_name', title: '商家名称'},
{templet: '#row-state', title: '状态'},
]],
done: function () {
Tools.setInsTb(insTb);
}
});
}
/*** index end ***/
});

View File

@ -0,0 +1,79 @@
{layout name="manager/layout" /}
<style>
.layui-table-cell{
height: auto;
white-space: normal;
}
.layui-table .layui-layer-photos {height: 90px;}
.layui-table img{
max-height: 100%;
object-fit: cover;
margin-left: auto;
margin-right: auto;
display: block;
max-width: 150px;
vertical-align: middle;
border: 0;
}
</style>
<div class="layui-row layui-col-space12">
<div class="layui-col-xs12 layui-col-md12">
<div id="echarts-records" style="background-color:#ffffff;min-height:600px;">
<div class="layuimini-container location-index-page">
<div class="layuimini-main">
<fieldset class="table-search-fieldset" style="display: none">
<legend>搜索信息</legend>
<div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<label class="layui-form-label">关键词</label>
<div class="layui-inline">
<input type="text" name="keyword" class="layui-input">
</div>
<label class="layui-form-label">状态</label>
<div class="layui-inline">
<select name="state" id="">
<option value=""></option>
{foreach $state as $key=> $sitem }
<option value="{$key}">{$sitem}</option>
{/foreach}
</select>
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
</div>
</div>
</form>
</div>
</fieldset>
<div>
<table id="table-container" class="layui-table" data-url="/manager/consumer/index" lay-filter="table-container"></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 操作列 -->
<script type="text/html" id="row-operate">
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/info.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】详情" lay-event="">详情</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/consumer/edit.html?id={{d.id}}" data-title="消费者【{{ d.nick_name }}】审核修改" lay-event="">审核修改</a>
</script>
<!-- toolbar -->
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
</script>
<!-- 列 轮播图 -->
<script type="text/html" id="row-cover">
<div class="layui-layer-photos">
<img src="{{ d.avatar_url }}" layer-src="{{ d.avatar_url }}" alt="">
</div>
</script>
<script src="__MANAGER__/js/consumer/index.js?v={:mt_rand()}"></script>

View File

@ -0,0 +1,124 @@
{layout name="manager/layout" /}
<style>
.layui-table-cell{
height: auto;
white-space: normal;
}
.layui-table .layui-layer-photos {height: 90px;}
.layui-table img{
max-height: 100%;
object-fit: cover;
margin-left: auto;
margin-right: auto;
display: block;
max-width: 150px;
vertical-align: middle;
border: 0;
}
#avatar{
max-width: 100%;
display: block;
margin: auto;
}
</style>
<div class="layui-row layui-col-space12">
<div class="layui-row layui-col-space15">
<div class="layui-col-md2">
<div class="layui-col-md12">
<div class="layui-layer-photos">
<img id="avatar" src="{$consumer.avatar_url}" layer-src="{$consumer.avatar_url}" alt="">
</div>
</div>
</div>
<div class="layui-col-md10">
<div class="layui-col-md12">
<div class="layui-col-md4">
<div class="layui-panel" style="border-radius: 8px;">
<div class="layui-row" style="padding: 5% 0;text-align: center">
<h3><strong>评论数</strong></h3>
<span style="font-size: 36px">{$totalComment ?? 0}</span>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-panel" style="border-radius: 8px;">
<div class="layui-row" style="padding: 5% 0;text-align: center">
<h3><strong>本月评论数</strong></h3>
<span style="font-size: 36px">{$totalTheMonthComment ?? 0}</span>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-panel" style="border-radius: 8px;">
<div class="layui-row" style="padding: 5% 0;text-align: center">
<h3><strong>标签</strong></h3>
<span style="font-size: 32px">{$consumer["tag"]["name"] ?? '无'}</span>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-panel" style="border-radius: 8px;">
<div class="layui-row" style="padding: 5% 0;text-align: center">
<h3><strong>优惠券领取总数</strong></h3>
<span style="font-size: 36px">{$couponTotalCount ?? 0}</span>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-panel" style="border-radius: 8px;">
<div class="layui-row" style="padding: 5% 0;text-align: center">
<h3><strong>优惠券使用总数</strong></h3>
<span style="font-size: 36px">{$couponUsedTotalCount ?? 0}</span>
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-panel" style="border-radius: 8px;">
<div class="layui-row" style="padding: 5% 0;text-align: center">
<h3><strong>优惠券未使用总数</strong></h3>
<span style="font-size: 36px">{$couponNotUsedTotalCount ?? 0}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-md12">
<div id="echarts-records" style="background-color:#ffffff;min-height:600px;">
<div class="layuimini-container location-index-page">
<div class="layuimini-main">
<div>
<table id="table-container" class="layui-table" data-url="/manager/consumer/info.html?id={$consumer.id}" lay-filter="table-container"></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 操作列 -->
<script type="text/html" id="row-state">
{{ d.time_state }}
|
{{# if(d.is_verificated == 1){ }}
已验证
{{# }else{ }}
未验证
{{# } }}
</script>
<!-- toolbar -->
<script type="text/html" id="toolbar-tpl">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
</script>
<script src="__MANAGER__/js/consumer/info.js?v={:mt_rand()}"></script>