[更新]商城模块开发[提交中间代码]

This commit is contained in:
Anyon 2018-04-21 16:29:55 +08:00
parent 47f525d040
commit 40cf143a29
9 changed files with 963 additions and 2 deletions

View File

@ -36,8 +36,8 @@ class ProductService
$cateWhere = ['status' => '1', 'is_deleted' => '0']; $cateWhere = ['status' => '1', 'is_deleted' => '0'];
$cateList = Db::name('GoodsCate')->where($cateWhere)->order('sort asc,id desc')->column($cateField); $cateList = Db::name('GoodsCate')->where($cateWhere)->order('sort asc,id desc')->column($cateField);
// 产品品牌处理 // 产品品牌处理
$brandField = 'id,brand_logo,brand_cover,brand_title,brand_desc,brand_detail';
$brandWhere = ['status' => '1', 'is_deleted' => '0']; $brandWhere = ['status' => '1', 'is_deleted' => '0'];
$brandField = 'id,brand_logo,brand_cover,brand_title,brand_desc,brand_detail';
$brandList = Db::name('GoodsBrand')->where($brandWhere)->order('sort asc,id desc')->column($brandField); $brandList = Db::name('GoodsBrand')->where($brandWhere)->order('sort asc,id desc')->column($brandField);
// 无产品列表时 // 无产品列表时
if (empty($goodsList)) { if (empty($goodsList)) {

View File

@ -0,0 +1,126 @@
<?php
// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace app\store\controller;
use controller\BasicAdmin;
use service\DataService;
use think\Db;
/**
* 商城快递公司管理
* Class Express
* @package app\store\controller
* @author Anyon <zoujingli@qq.com>
* @date 2017/03/27 14:43
*/
class Express extends BasicAdmin
{
/**
* 定义当前操作表名
* @var string
*/
public $table = 'StoreExpress';
/**
* 快递公司列表
* @return array|string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$this->title = '快递公司管理';
list($get, $db) = [$this->request->get(), Db::name($this->table)];
foreach (['express_title', 'express_code'] as $field) {
(isset($get[$field]) && $get[$field] !== '') && $db->whereLike($field, "%{$get[$field]}%");
}
if (isset($get['date']) && $get['date'] !== '') {
list($start, $end) = explode(' - ', $get['date']);
$db->whereBetween('create_at', ["{$start} 00:00:00", "{$end} 23:59:59"]);
}
return parent::_list($db->where(['is_deleted' => '0'])->order('status desc,sort asc,id desc'));
}
/**
* 添加快递公司
* @return array|string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function add()
{
$this->title = '添加快递公司';
return $this->_form($this->table, 'form');
}
/**
* 编辑快递公司
* @return array|string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function edit()
{
$this->title = '编辑快递公司';
return $this->_form($this->table, 'form');
}
/**
* 删除快递公司
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function del()
{
if (DataService::update($this->table)) {
$this->success("快递公司删除成功!", '');
}
$this->error("快递公司删除失败,请稍候再试!");
}
/**
* 快递公司禁用
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
if (DataService::update($this->table)) {
$this->success("快递公司禁用成功!", '');
}
$this->error("快递公司禁用失败,请稍候再试!");
}
/**
* 快递公司禁用
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
if (DataService::update($this->table)) {
$this->success("快递公司启用成功!", '');
}
$this->error("快递公司启用失败,请稍候再试!");
}
}

View File

@ -0,0 +1,157 @@
<?php
// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace app\store\controller;
use app\store\service\OrderService;
use controller\BasicAdmin;
use service\DataService;
use think\Db;
/**
* 商店订单管理
* Class Order
* @package app\store\controller
* @author Anyon <zoujingli@qq.com>
* @date 2017/03/27 14:43
*/
class Order extends BasicAdmin
{
/**
* 定义当前操作表名
* @var string
*/
public $table = 'StoreOrder';
/**
* 订单列表
* @return array|string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$this->title = '订单管理';
$db = Db::name($this->table);
$get = $this->request->get();
// 会员信息查询过滤
$memberWhere = [];
foreach (['phone', 'nickname'] as $field) {
if (isset($get[$field]) && $get[$field] !== '') {
$memberWhere[] = [$field, 'like', "%{$get[$field]}%"];
}
}
if (!empty($memberWhere)) {
$memberWhere['status'] = '1';
$sql = Db::name('Member')->field('id')->where($memberWhere)->buildSql(true);
$db->where("mid in {$sql}");
}
// =============== 商品信息查询过滤 ===============
$goodsWhere = [];
foreach (['goods_title'] as $field) {
if (isset($get[$field]) && $get[$field] !== '') {
$goodsWhere[] = [$field, 'like', "%{$get[$field]}%"];
}
}
if (!empty($goodsWhere)) {
$sql = Db::name('StoreOrderList')->field('order_no')->where($goodsWhere)->buildSql(true);
$db->where("order_no in {$sql}");
}
// =============== 收货地址过滤 ===============
$expressWhere = [];
if (isset($get['express_title']) && $get['express_title'] !== '') {
$expressWhere[] = ['real_express_title|express_title', 'like', "%{$get['express_title']}%"];
}
foreach (['real_express_no', 'express_province', 'express_city', 'express_area', 'express_username', 'express_phone'] as $field) {
if (isset($get[$field]) && $get[$field] !== '') {
$expressWhere[] = [$field, 'like', "%{$get[$field]}%"];
}
}
if (isset($get['send_status']) && $get['send_status'] !== '') {
$expressWhere[] = empty($get['send_status']) ? ['real_express_no', 'eq', ''] : ['real_express_no', 'neq', ''];
}
if (!empty($expressWhere)) {
$sql = Db::name('StoreOrderExpress')->field('order_no')->where($expressWhere)->buildSql(true);
$db->where("order_no in {$sql}");
}
// =============== 主订单过滤 ===============
foreach (['order_no', 'desc'] as $field) {
(isset($get[$field]) && $get[$field] !== '') && $db->whereLike($field, "%{$get[$field]}%");
}
(isset($get['status']) && $get['status'] !== '') && $db->where('status', $get['status']);
// 订单是否包邮状态检索
if (isset($get['express_zero']) && $get['express_zero'] !== '') {
empty($get['express_zero']) ? $db->where('freight_price', '>', '0') : $db->where('freight_price', '0');
}
// 订单时间过滤
foreach (['create_at', 'pay_at'] as $field) {
if (isset($get[$field]) && $get[$field] !== '') {
list($start, $end) = explode(' - ', $get[$field]);
$db->whereBetween($field, ["{$start} 00:00:00", "{$end} 23:59:59"]);
}
}
return parent::_list($db);
}
/**
* 订单列表数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function _data_filter(&$data)
{
OrderService::buildOrderList($data);
}
/**
* 订单地址修改
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\Exception
*/
public function address()
{
$order_no = $this->request->get('order_no');
if ($this->request->isGet()) {
$order = Db::name('StoreOrder')->where(['order_no' => $order_no])->find();
empty($order) && $this->error('该订单无法进行地址修改,订单数据不存在!');
$orderExpress = Db::name('StoreOrderExpress')->where(['order_no' => $order_no])->find();
empty($orderExpress) && $this->error('该订单无法进行地址修改!');
return $this->fetch('', $orderExpress);
}
$data = [
'order_no' => $order_no,
'express_username' => $this->request->post('express_username'),
'express_phone' => $this->request->post('express_phone'),
'express_province' => $this->request->post('form_express_province'),
'express_city' => $this->request->post('form_express_city'),
'express_area' => $this->request->post('form_express_area'),
'express_address' => $this->request->post('express_address'),
'express_desc' => $this->request->post('express_desc'),
];
if (DataService::save('StoreOrderExpress', $data, 'order_no')) {
$this->success('收货地址修改成功!', '');
}
$this->error('收货地址修改失败,请稍候再试!');
}
}

View File

@ -0,0 +1,185 @@
<?php
// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace app\store\service;
use Pay\Pay;
use service\DataService;
use service\ToolsService;
use think\Db;
/**
* 商城订单服务
* Class OrderService
* @package app\store
*/
class OrderService
{
/**
* 商城创建订单
* @param int $mid 会员ID
* @param string $params 商品参数规格 (商品ID@商品规格@购买数量;商品ID@商品规格@购买数量)
* @param int $addressId 地址记录ID
* @param int $expressId 快递记录ID
* @param string $orderDesc 订单描述
* @param integer $orderType 订单类型
* @param string $from 订单来源
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function create($mid, $params, $addressId = 0, $expressId = 0, $orderDesc = '', $orderType = 1, $from = 'wechat')
{
// 会员数据获取与检验
if (!($member = Db::name('StoreMember')->where(['id' => $mid])->find())) {
return ['code' => 0, 'msg' => '会员数据处理异常,请刷新重试!'];
}
// 订单数据生成
list($order_no, $orderList) = [[], DataService::createSequence(10, 'ORDER'), []];
$order = ['mid' => $mid, 'order_no' => $order_no, 'real_price' => 0, 'total_price' => 0, 'desc' => $orderDesc, 'type' => $orderType, 'from' => $from,];
foreach (explode(';', trim($params, ',;@')) as $param) {
list($goods_id, $goods_spec, $number) = explode('@', "{$param}@@");
$item = ['mid' => $mid, 'type' => $orderType, 'order_no' => $order_no, 'goods_id' => $goods_id, 'goods_spec' => $goods_spec, 'goods_number' => $number,];
$goodsResult = self::buildOrderData($item, $order, $orderList, 'selling_price');
if (empty($goodsResult['code'])) {
return $goodsResult;
}
}
// 生成快递信息
$expressResult = self::buildExpressData($order, $addressId, $expressId);
if (empty($expressResult['code'])) {
return $expressResult;
}
try {
// 写入订单信息
Db::transaction(function () use ($order, $orderList, $expressResult) {
Db::name('StoreOrder')->insert($order); // 主订单信息
Db::name('StoreOrderGoods')->insertAll($orderList); // 订单关联的商品信息
Db::name('storeOrderExpress')->insert($expressResult['data']); // 快递信息
});
// @todo 同步相关商品库存
} catch (\Exception $e) {
return ['code' => 0, 'msg' => '商城订单创建失败,请稍候再试!' . $e->getLine() . $e->getFile() . $e->getMessage()];
}
return ['code' => 1, 'msg' => '商城订单创建成功!', 'order_no' => $order_no];
}
/**
* 生成订单快递数据
* @param array $order 订单主表记录
* @param int $address_id 会员地址ID
* @param int $express_id 快递信息ID
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function buildExpressData(&$order, $address_id, $express_id)
{
// 收货地址处理
$addressWhere = ['mid' => $order['mid'], 'id' => $address_id, 'status' => '1', 'is_deleted' => '0'];
$addressField = 'username express_username,phone express_phone,province express_province,city express_city,area express_area,address express_address';
if (!($address = Db::name('StoreMemberAddress')->field($addressField)->where($addressWhere)->find())) {
return ['code' => 0, 'msg' => '收货地址数据异常!'];
}
// 物流信息查询
$expressField = 'express_title,express_code';
$expressWhere = ['id' => $express_id, 'status' => '1', 'is_deleted' => '0'];
if (!($express = Db::name('StoreExpress')->field($expressField)->where($expressWhere)->find())) {
return ['code' => 0, 'msg' => '快递公司数据异常!'];
}
// @todo 运费计算处理
// $order['freight_price'] = '0.00';
// $order['real_price'] += floatval($order['freight_price']);
$extend = ['mid' => $order['mid'], 'order_no' => $order['order_no'], 'type' => $order['type']];
return ['code' => 1, 'data' => array_merge($address, $express, $extend), 'msg' => '生成快递信息成功!'];
}
/**
* 订单数据生成
* @param array $item 订单单项参数
* (mid,type,order_no,goods_id,goods_spec,goods_number)
* @param array $order 订单主表
* @param array $orderList 订单详细表
* @param string $price_field 实际计算单价字段
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private static function buildOrderData($item, &$order, &$orderList, $price_field = 'selling_price')
{
list($mid, $type, $order_no, $goods_id, $goods_spec, $number) = [
$item['mid'], $item['type'], $item['order_no'], $item['goods_id'], $item['goods_spec'], $item['goods_number'],
];
// 商品主体信息
$goodsField = 'goods_title,goods_logo,goods_image';
$goodsWhere = ['id' => $goods_id, 'status' => '1', 'is_deleted' => '0'];
if (!($goods = Db::name('StoreGoods')->field($goodsField)->where($goodsWhere)->find())) {
return ['code' => 0, 'msg' => "无效的商品信息!", 'data' => "{$goods_id}, {$goods_spec}, {$number}"];
}
// 商品规格信息
$specField = 'goods_id,goods_spec,market_price,selling_price,goods_stock,goods_sale';
$specWhere = ['status' => '1', 'is_deleted' => '0', 'package_id' => '0', 'goods_id' => $goods_id, 'goods_spec' => $goods_spec];
if (!($goodsSpec = Db::name('StoreGoodsList')->field($specField)->where($specWhere)->find())) {
return ['code' => 0, 'msg' => '无效的商品规格信息!', 'data' => "{$goods_id}, {$goods_spec}, {$number}"];
}
if ($goodsSpec['goods_stock'] - $goodsSpec['goods_sale'] < $number) {
return ['code' => 0, 'msg' => '商品库存不足,请更换其它商品!', 'data' => "{$goods_id}, {$goods_spec}, {$number}"];
}
$goodsSpec['price_field'] = $price_field;
$orderList[] = array_merge($goods, $goodsSpec, ['mid' => $mid, 'number' => $number, 'order_no' => $order_no, 'type' => $type]);
$order['goods_price'] += floatval($goodsSpec[$price_field]) * $number;
$order['real_price'] += floatval($goodsSpec[$price_field]) * $number;
return ['code' => 1, 'msg' => '商品添加到订单成功!'];
}
/**
* 订单主表数据处理
* @param array $list
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function buildOrderList(&$list)
{
$mids = array_unique(array_column($list, 'mid'));
$orderNos = array_unique(array_column($list, 'order_no'));
$memberList = Db::name("StoreMember")->whereIn('id', $mids)->select();
$goodsList = Db::name('StoreOrderGoods')->whereIn('order_no', $orderNos)->select();
$expressList = Db::name('StoreOrderExpress')->whereIn('order_no', $orderNos)->select();
foreach ($list as $key => $vo) {
list($list[$key]['member'], $list[$key]['goods'], $list[$key]['express']) = [[], [], []];
foreach ($memberList as $member) {
$member['nickname'] = ToolsService::emojiDecode($member['nickname']);
($vo['mid'] === $member['id']) && $list[$key]['member'] = $member;
}
foreach ($expressList as $express) {
($vo['order_no'] === $express['order_no']) && $list[$key]['express'] = $express;
}
foreach ($goodsList as $goods) {
if ($goods['goods_spec'] === 'default:default') {
$goods['goods_spec_alias'] = '<span class="color-desc">默认规格</span>';
} else {
$goods['goods_spec_alias'] = str_replace([':', ','], ['', ''], $goods['goods_spec']);
}
($vo['order_no'] === $goods['order_no']) && $list[$key]['goods'][] = $goods;
}
}
return $list;
}
}

View File

@ -0,0 +1,36 @@
<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="{:request()->url()}" data-auto="true" method="post">
<div class="layui-form-item">
<label class="layui-form-label">快递公司名称</label>
<div class="layui-input-block">
<input autofocus name="express_title" value='{$vo.express_title|default=""}' required="required"
title="请输入快递公司名称" placeholder="请输入快递公司名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">快递公司代码</label>
<div class="layui-input-block">
<input autofocus name="express_code" value='{$vo.express_code|default=""}' required="required"
title="请输入快递公司代码" placeholder="请输入快递公司代码" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">快递公司描述</label>
<div class="layui-input-block">
<textarea placeholder="请输入快递公司描述" title="请输入快递公司描述"
class="layui-textarea" name="express_desc">{$vo.express_desc|default=""}</textarea>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
{if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
<script>window.form.render();</script>
</form>

View File

@ -0,0 +1,117 @@
{extend name='admin@public/content'}
{block name="button"}
<!--{if auth("$classuri/add")}-->
<button data-modal='{:url("$classuri/add")}' data-title="添加快递" class='layui-btn layui-btn-sm'>添加快递</button>
<!--{/if}-->
<!--{if auth("$classuri/del")}-->
<button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-sm layui-btn-danger'>删除快递</button>
<!--{/if}-->
{/block}
{block name="content"}
<!-- 表单搜索 开始 -->
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">快递公司</label>
<div class="layui-input-inline">
<input name="express_title" value="{$Think.get.express_title}" placeholder="请输入快递名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">快递代码</label>
<div class="layui-input-inline">
<input name="express_code" value="{$Think.get.express_code}" placeholder="请输入快递代码" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">添加时间</label>
<div class="layui-input-inline">
<input name="date" id="range-date" value="{$Think.get.date}" placeholder="请选择添加时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
<script>
window.laydate.render({range: true, elem: '#range-date'});
window.form.render();
</script>
<!-- 表单搜索 结束 -->
<form onsubmit="return false;" data-auto="true" method="post">
<input type="hidden" value="resort" name="action"/>
{if empty($list)}
<p class="help-block text-center well"> 哦!</p>
{else}
<table class="layui-table" lay-skin="line" lay-size="sm">
<thead>
<tr>
<th class='list-table-check-td'>
<input data-auto-none="none" data-check-target='.list-check-box' type='checkbox'/>
</th>
<th class='list-table-sort-td'>
<button type="submit" class="layui-btn layui-btn-normal layui-btn-xs"> </button>
</th>
<th class='text-left'>快递公司</th>
<th class='text-left'>快递代码</th>
<th class='text-left'>添加时间</th>
<th class='text-left'>快递状态</th>
<th class='text-left'>操作</th>
</tr>
</thead>
<tbody>
{foreach $list as $key=>$vo}
<tr>
<td class='list-table-check-td'>
<input class="list-check-box" value='{$vo.id}' type='checkbox'/>
</td>
<td class='list-table-sort-td'>
<input name="_{$vo.id}" value="{$vo.sort}" class="list-sort-input"/>
</td>
<td class='text-left'>{$vo.express_title}</td>
<td class='text-left'>{$vo.express_code}</td>
<td class='text-left'>{$vo.create_at|format_datetime}</td>
<td class='text-left'>
{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">使用中</span>{/if}
</td>
<td class='text-left nowrap'>
<!--{if auth("$classuri/edit")}-->
<span class="text-explode">|</span>
<a data-title="编辑快递" data-modal='{:url("$classuri/edit")}?id={$vo.id}'>编辑</a>
<!--{/if}-->
<!--{if $vo.status eq 1 and auth("$classuri/forbid")}-->
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}'>禁用</a>
<!--{elseif auth("$classuri/resume")}-->
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}'>启用</a>
<!--{/if}-->
{if auth("$classuri/del")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}'>删除</a>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{if isset($page)}<p>{$page|raw}</p>{/if}
{/if}
</form>
{/block}

View File

@ -0,0 +1,60 @@
<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="{:request()->url()}" data-auto="true" method="post">
<div class="layui-form-item">
<label class="layui-form-label">收货人姓名</label>
<div class="layui-input-block">
<input class="layui-input" required placeholder="请输入收货人姓名" title="请输入收货人姓名" name="express_username" value="{$express_username}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">收货人手机</label>
<div class="layui-input-block">
<input class="layui-input" pattern="^1\d{10}$" required placeholder="请输入收货人手机" title="请输入收货人手机" name="express_phone" value="{$express_phone}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">收货省市区</label>
<div class="layui-input-block">
<div class="layui-col-xs4 padding-right-5">
<select name="form_express_province" class="layui-select block full-width" lay-ignore></select>
</div>
<div class="layui-col-xs4 padding-right-5">
<select name="form_express_city" class="layui-select block full-width" lay-ignore></select>
</div>
<div class="layui-col-xs4">
<select name="form_express_area" class="layui-select block full-width" lay-ignore></select>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">详细地址</label>
<div class="layui-input-block">
<textarea required placeholder="请输入详细地址" title="请输入详细地址" name="express_address" class="layui-textarea">{$express_address|default=""}</textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注</label>
<div class="layui-input-block">
<textarea required placeholder="请输入备注" title="请输入备注" name="express_desc" class="layui-textarea">{$express_desc|default=""}</textarea>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
{if isset($order_no)}<input type='hidden' value='{$order_no}' name='order_no'>{/if}
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
<script>
require(['pcasunzips'], function () {
new PCAS('form_express_province', 'form_express_city', 'form_express_area', '{$express_province}', '{$express_city}', '{$express_area}');
});
</script>
</form>

View File

@ -0,0 +1,280 @@
{extend name='admin@public/content'}
{block name="content"}
<!-- 表单搜索 开始 -->
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">会员手机</label>
<div class="layui-input-inline">
<input name="phone" value="{$Think.get.phone}" placeholder="请输入会员手机" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">会员昵称</label>
<div class="layui-input-inline">
<input name="nickname" value="{$Think.get.nickname}" placeholder="请输入会员昵称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">订单单号</label>
<div class="layui-input-inline">
<input name="order_no" value="{$Think.get.order_no}" placeholder="请输入订单单号" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">订单状态</label>
<div class="layui-input-inline">
<select name="status" class="layui-select">
<option value="">所有订单</option>
<!--{foreach ["已取消","待付款","待发货","已发货","已完成","已退单","退单审核中","退款处理中"] as $k=>$v}-->
{if $Think.get.status eq "$k"}
<option selected="selected" value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/if}
<!--{/foreach}-->
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">商品名称</label>
<div class="layui-input-inline">
<input name="goods_title" value="{$Think.get.goods_title}" placeholder="请输入商品名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">发货状态</label>
<div class="layui-input-inline">
<select name="send_status" class="layui-select">
<option value="">所有订单</option>
{foreach ['未发货','已发货'] as $k=>$v}
{if $Think.get.send_status eq "$k"}
<option selected="selected" value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/if}
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">是否包邮</label>
<div class="layui-input-inline">
<select name="express_zero" class="layui-select">
<option value="">所有订单</option>
{if $Think.get.express_zero == '0'}
<option selected="selected" value="0">不包邮</option>
{else}
<option value="0">不包邮</option>
{/if}
{if $Think.get.express_zero eq 1}
<option selected="selected" value="1">包邮</option>
{else}
<option value="1">包邮</option>
{/if}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">下单时间</label>
<div class="layui-input-inline">
<input name="create_at" data-time value="{$Think.get.create_at}" placeholder="请选择下单时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">支付时间</label>
<div class="layui-input-inline">
<input name="pay_at" data-time value="{$Think.get.pay_at}" placeholder="请选择支付时间间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">订单描述</label>
<div class="layui-input-inline">
<input name="order_desc" value="{$Think.get.order_desc}" placeholder="请输入订单描述" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">物流公司</label>
<div class="layui-input-inline">
<input name="express_title" value="{$Think.get.express_title}" placeholder="请输入物流公司" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">快递单号</label>
<div class="layui-input-inline">
<input name="real_express_no" value="{$Think.get.real_express_no}" placeholder="请输入快递单号" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货姓名</label>
<div class="layui-input-inline">
<input name="express_username" value="{$Think.get.express_username}" placeholder="请输入收货姓名" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货手机</label>
<div class="layui-input-inline">
<input name="express_phone" value="{$Think.get.express_phone}" placeholder="请输入收货手机" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货省份</label>
<div class="layui-input-inline">
<input name="express_province" value="{$Think.get.express_province}" placeholder="请输入收货省份" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货城市</label>
<div class="layui-input-inline">
<input name="express_city" value="{$Think.get.express_city}" placeholder="请输入收货城市" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货区域</label>
<div class="layui-input-inline">
<input name="express_area" value="{$Think.get.express_area}" placeholder="请输入收货区域" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
<script>
window.form.render();
$('[data-time]').map(function () {
window.laydate.render({range: true, elem: this});
});
</script>
<!-- 表单搜索 结束 -->
<form onsubmit="return false;" data-auto="true" method="post">
{if empty($list)}
<p class="help-block text-center well"> 哦!</p>
{else}
<table class="layui-table" lay-size="sm">
<thead>
<tr>
<th class='list-table-check-td'>
<input data-auto-none="none" data-check-target='.list-check-box' type='checkbox'/>
</th>
<th class="text-left">会员信息</th>
<th class="text-left">订单信息</th>
<th class="text-left nowrap padding-none">
<table class="layui-table think-inner-table">
<colgroup>
<col width="70%">
</colgroup>
<tr>
<td>商品信息</td>
<td class="text-right">
价格 <span class="layui-icon font-s12">&#x1006;</span> 数量
</td>
</tr>
</table>
</th>
<th class="text-left">发货信息</th>
</tr>
</thead>
<tbody>
{foreach $list as $key=>$vo}
<tr>
<td class='list-table-check-td text-top'>
<input class="list-check-box" value='{$vo.id}' type='checkbox'/>
</td>
<td class="text-left text-top nowrap">
会员昵称:{$vo.member.nickname|default='<span class="color-desc">未设置会员昵称</span>'}<br>
会员手机:{$vo.member.phone|default='<span class="color-desc">未设置会员手机</span>'}
</td>
<td class="text-left text-top nowrap">
订单单号:<b>{$vo.order_no}</b> {if $vo.type eq 3}<span class="layui-badge-rim">套餐</span> {/if}
{switch name='vo.status'}
{case value='0'}<span class="layui-badge layui-bg-gray">已取消</span>{/case}
{case value='1'}<span class="layui-badge layui-bg-black">待付款</span>{/case}
{case value='2'}<span class="layui-badge layui-bg-blue">待发货</span>{/case}
{case value='3'}<span class="layui-badge layui-bg-orange">已发货</span>{/case}
{case value='4'}<span class="layui-badge layui-bg-green">已完成</span>{/case}
{case value='5'}<span class="layui-badge layui-bg-gray">已退单</span>{/case}
{case value='6'}<span class="layui-badge layui-bg-red">退款审核中({if($vo.refund_type == 1)}退款申请{/if}{if($vo.refund_type == 2)}退货申请{/if}</span>
<span class="margin-left-5"><a data-title="退款审核" data-modal="{:url('order/checkRefund')}?order_no={$vo.order_no}&id={$vo.id}">审核</a></span>{/case}
{case value='7'}<span class="layui-badge layui-bg-rown">退款处理中</span>{/case}
{/switch}
<br>
</td>
<td class="text-left text-top nowrap padding-none">
<table class="layui-table think-inner-table">
<colgroup>
<col width="70%">
</colgroup>
{foreach $vo.goods as $goods}
<tr>
<td>[{$goods.goods_id}] {$goods.goods_title}{$goods.goods_spec_alias}</td>
<td class="text-right">
<b>
{if in_array($vo.type,['1','3'])}
{$goods[$goods['price_field']]}
{else}
{$goods.selling_integral} 积分
{/if}
<span class="layui-icon font-s12">&#x1006;</span>
{$goods.number}
</b>
</td>
</tr>
{/foreach}
</table>
</td>
<td class="text-left text-top nowrap">
{if empty($vo.express)}
<span class="color-desc">无发货信息</span>
{else}
快递公司:{$vo.express.real_express_title|default=$vo.express.express_title}
{if !empty($vo.express.real_express_title)}
<!--<span class="color-desc">{$vo.express.real_express_at|format_datetime|default='未发货'}</span>-->
{if $vo.express.real_express_title neq $vo.express.express_title}
<s class="color-desc">{$vo.express.express_title}</s>
{/if}
{/if}
<br>
快递单号:{$vo.express.real_express_no|default='<span class="layui-badge layui-bg-blue">未发货</span>'|raw}
<!--{if auth('store/deliver/tracking') and !empty($vo.express.real_express_no)}-->
<a data-modal="{:url('store/deliver/tracking')}?express_code={$vo.express.real_express_code}&express_no={$vo.express.real_express_no}&express_title={$vo.express.real_express_title}" data-title="追踪物流">查看</a>
<!--{elseif auth('store/deliver/express') and $vo.status eq 2 and $vo.is_pay eq 1}-->
<a data-title="快速发货" data-modal="{:url('store/deliver/express')}?order_no={$vo.order_no}">快速发货</a>
<!--{/if}-->
<br>
收货信息:{$vo.express.express_username} {$vo.express.express_phone}<br>
收货地址:{$vo.express.express_province}{$vo.express.express_city}{$vo.express.express_area}{$vo.express.express_address}
{if auth('store/order/address')}<a data-title="修改收货人信息" data-modal="{:url('order/address')}?order_no={$vo.order_no}">修改</a>{/if}
{/if}
{if !empty($vo.express.real_express_at)}<br>发货时间:{$vo.express.real_express_at|format_datetime}{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{if isset($page)}<p>{$page|raw}</p>{/if}
{/if}
</form>
{/block}

View File

@ -115,7 +115,7 @@ class BasicAdmin extends Controller
$rows = intval($this->request->get('rows', cookie('page-rows'))); $rows = intval($this->request->get('rows', cookie('page-rows')));
cookie('page-rows', $rows = $rows >= 10 ? $rows : 20); cookie('page-rows', $rows = $rows >= 10 ? $rows : 20);
// 分页数据处理 // 分页数据处理
$query = $this->request->get('', '', 'urlencode'); $query = $this->request->get();
$page = $db->paginate($rows, $total, ['query' => $query]); $page = $db->paginate($rows, $total, ['query' => $query]);
if (($totalNum = $page->total()) > 0) { if (($totalNum = $page->total()) > 0) {
list($rowsHTML, $pageHTML, $maxNum) = [[], [], $page->lastPage()]; list($rowsHTML, $pageHTML, $maxNum) = [[], [], $page->lastPage()];