|
@@ -3,19 +3,20 @@
|
|
|
namespace app\admin\logic;
|
|
|
|
|
|
use app\model\CommonModel;
|
|
|
-use app\model\OrderExchangeModel;
|
|
|
+use app\model\GoodModel;
|
|
|
+use app\model\OrderModel;
|
|
|
use think\Exception;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Validate;
|
|
|
use think\response\Json;
|
|
|
|
|
|
-class OrderExchangeLogic extends BaseLogic
|
|
|
+class OrderLogic extends BaseLogic
|
|
|
{
|
|
|
//列表
|
|
|
public static function list(array $data = []): Json
|
|
|
{
|
|
|
|
|
|
- $db = OrderExchangeModel::alias('a')
|
|
|
+ $db = OrderModel::alias('a')
|
|
|
->leftJoin('company b', 'b.id=a.company_id AND b.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('card c', 'c.id=a.card_id AND c.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('account d', 'd.id=a.uid AND d.is_del=' . CommonModel::$del_normal)
|
|
@@ -28,30 +29,31 @@ class OrderExchangeLogic extends BaseLogic
|
|
|
if ($data['name'] !== '') $db->whereLike('d.name', '%' . $data['name'] . '%');
|
|
|
if ($data['username']) $db->whereLike('d.username', '%' . $data['username'] . '%');
|
|
|
if (($data['start_date'] != '') && ($data['end_date'] != '')) $db->whereBetween('a.addtime', [$data['start_date'], $data['end_date']]);
|
|
|
+ if ($data['type'] !== '') $db->where('a.type', $data['type']);
|
|
|
|
|
|
$count = $db->count('a.id');
|
|
|
|
|
|
$list = $db
|
|
|
- ->field('a.id,a.orderCode,b.title company_title,c.title card_title,d.name,d.username,a.num,e.contactor,e.mobile,a.status,a.post_name,a.post_code,a.addtime,e.addr_code,"" addr_name,e.addr,f.good_code,f.good_name,f.good_cover_img')
|
|
|
+ ->field('a.id,a.orderCode,a.type,b.title company_title,c.title card_title,d.name,d.username,a.num,e.contactor,e.mobile,a.status,a.post_name,a.post_code,a.addtime,e.addr_code,"" addr_name,e.addr,f.good_code,f.good_name,f.good_cover_img')
|
|
|
->page($data['page'], $data['size'])
|
|
|
->withAttr('addr_code', function ($val) {
|
|
|
return explode(',', $val);
|
|
|
})
|
|
|
->withAttr('addr_name', function ($val, $da) {
|
|
|
- return $da['addr_code']?get_addr_name($da['addr_code']):'';
|
|
|
+ return $da['addr_code'] ? get_addr_name($da['addr_code']) : '';
|
|
|
})
|
|
|
->order('a.addtime desc')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|
|
|
- return json_show(CommonModel::$success, '获取兑换订单列表成功', ['count' => $count, 'list' => $list]);
|
|
|
+ return json_show(CommonModel::$success, '获取订单列表成功', ['count' => $count, 'list' => $list]);
|
|
|
}
|
|
|
|
|
|
//详情
|
|
|
public static function read(int $id = 0): Json
|
|
|
{
|
|
|
- $rs = $db = OrderExchangeModel::alias('a')
|
|
|
- ->field('a.id,a.orderCode,b.title company_title,c.title card_title,d.name,d.username,a.num,e.contactor,e.mobile,e.addr_code,a.status,a.post_name,a.post_code,a.addtime,"" addr_name,f.good_code,f.good_name,f.good_cover_img')
|
|
|
+ $rs = $db = OrderModel::alias('a')
|
|
|
+ ->field('a.id,a.orderCode,a.type,b.title company_title,c.title card_title,d.name,d.username,a.num,e.contactor,e.mobile,e.addr_code,a.status,a.post_name,a.post_code,a.addtime,"" addr_name,f.good_code,f.good_name,f.good_cover_img')
|
|
|
->leftJoin('company b', 'b.id=a.company_id AND b.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('card c', 'c.id=a.card_id AND c.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('account d', 'd.id=a.uid AND d.is_del=' . CommonModel::$del_normal)
|
|
@@ -62,7 +64,7 @@ class OrderExchangeLogic extends BaseLogic
|
|
|
return explode(',', $val);
|
|
|
})
|
|
|
->withAttr('addr_name', function ($val, $da) {
|
|
|
- return $da['addr_code']?get_addr_name($da['addr_code']):'';
|
|
|
+ return $da['addr_code'] ? get_addr_name($da['addr_code']) : '';
|
|
|
})
|
|
|
->findOrEmpty()
|
|
|
->toArray();
|
|
@@ -73,7 +75,7 @@ class OrderExchangeLogic extends BaseLogic
|
|
|
public static function export(array $data = []): Json
|
|
|
{
|
|
|
|
|
|
- $db = OrderExchangeModel::alias('a')
|
|
|
+ $db = OrderModel::alias('a')
|
|
|
->leftJoin('company b', 'b.id=a.company_id AND b.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('card c', 'c.id=a.card_id AND c.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('account d', 'd.id=a.uid AND d.is_del=' . CommonModel::$del_normal)
|
|
@@ -86,21 +88,25 @@ class OrderExchangeLogic extends BaseLogic
|
|
|
if ($data['name'] !== '') $db->whereLike('d.name', '%' . $data['name'] . '%');
|
|
|
if ($data['username']) $db->whereLike('d.username', '%' . $data['username'] . '%');
|
|
|
if (($data['start_date'] != '') && ($data['end_date'] != '')) $db->whereBetween('a.addtime', [$data['start_date'], $data['end_date']]);
|
|
|
+ if ($data['type'] != '') $db->where('a.type', $data['type']);
|
|
|
|
|
|
$status = [CommonModel::$status_not_deliver => '待发货', CommonModel::$status_deliver => '已发货', CommonModel::$status_receipt => '已收货'];
|
|
|
+ $type = [GoodModel::$type_shopping => '商城', GoodModel::$type_exchange => '兑换'];
|
|
|
$list = $db
|
|
|
- ->field('a.id 订单ID,a.orderCode 订单编号,b.title 业务公司,c.title 卡类型,d.name 购买用户名,d.username 购买账号,a.num 购买数量,e.contactor 收货联系人,e.mobile 收货联系电话,e.addr_code,a.status 状态,a.post_name 物流公司,a.post_code 物流单号,a.addtime 创建时间,e.addr,f.good_code 商品编码,f.good_name 商品名称')
|
|
|
+ ->field('a.id 订单ID,a.orderCode 订单编号,a.type,b.title 业务公司,c.title 卡类型,d.name 购买用户名,d.username 购买账号,a.num 购买数量,e.contactor 收货联系人,e.mobile 收货联系电话,e.addr_code,a.status 状态,a.post_name 物流公司,a.post_code 物流单号,a.addtime 创建时间,e.addr,f.good_code 商品编码,f.good_name 商品名称')
|
|
|
->order('a.addtime desc')
|
|
|
->cursor();
|
|
|
|
|
|
$da = [];
|
|
|
foreach ($list as $v) {
|
|
|
$v = $v->toArray();
|
|
|
- $v['收货地址'] = $v['addr_code']?get_addr_name($v['addr_code']).$v['addr']:$v['addr'];
|
|
|
+ $v['收货地址'] = $v['addr_code'] ? get_addr_name($v['addr_code']) . $v['addr'] : $v['addr'];
|
|
|
$v['状态'] = $status[$v['状态']] ?? '';
|
|
|
+ $v['订单类型'] = $type[$v['type']] ?? '';
|
|
|
|
|
|
unset($v['addr_code']);
|
|
|
unset($v['addr']);
|
|
|
+ unset($v['type']);
|
|
|
|
|
|
$da[] = $v;
|
|
|
}
|
|
@@ -108,7 +114,7 @@ class OrderExchangeLogic extends BaseLogic
|
|
|
if (empty($da)) $da[] = '没有可供导出的数据';
|
|
|
|
|
|
$headerArr = array_keys($da[0]);
|
|
|
- excel_save('兑换订单导出' . date('YmdHis'), $headerArr, $da);
|
|
|
+ excel_save('订单导出' . date('YmdHis'), $headerArr, $da);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -116,7 +122,7 @@ class OrderExchangeLogic extends BaseLogic
|
|
|
public static function deliver(array $list = [])
|
|
|
{
|
|
|
|
|
|
- $db = new OrderExchangeModel();
|
|
|
+ $db = new OrderModel();
|
|
|
$temp = $db
|
|
|
->field('id,orderCode')
|
|
|
->where(['is_del' => CommonModel::$del_normal])
|