|
@@ -0,0 +1,79 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\admin\logic;
|
|
|
+
|
|
|
+use app\model\CommonModel;
|
|
|
+use app\model\OrderExchangeModel;
|
|
|
+use think\facade\Db;
|
|
|
+use think\response\Json;
|
|
|
+
|
|
|
+class OrderExchangeLogic extends BaseLogic
|
|
|
+{
|
|
|
+ //列表
|
|
|
+ public static function list(array $data = []): Json
|
|
|
+ {
|
|
|
+
|
|
|
+ $db = OrderExchangeModel::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)
|
|
|
+ ->leftJoin('addr e', 'e.id=a.addr_id AND e.is_del=' . CommonModel::$del_normal)
|
|
|
+ ->where('a.is_del', CommonModel::$del_normal);
|
|
|
+
|
|
|
+ if ($data['orderCode'] != '') $db->whereLike('a.orderCode', '%' . $data['orderCode'] . '%');
|
|
|
+ if ($data['status'] != '') $db->where('a.status', $data['status']);
|
|
|
+ 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']]);
|
|
|
+
|
|
|
+ $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,e.addr_code,a.status,a.post_name,a.post_code,a.addtime,e.addr_code,"" addr_name')
|
|
|
+ ->page($data['page'], $data['size'])
|
|
|
+ ->withAttr('addr_code', function ($val) {
|
|
|
+ return explode(',', $val);
|
|
|
+ })
|
|
|
+ ->withAttr('addr_name', function ($val, $da) {
|
|
|
+ $name = Db::name('area')
|
|
|
+ ->whereIn('code', $da['addr_code'])
|
|
|
+ ->column('name');
|
|
|
+ return implode($name);
|
|
|
+
|
|
|
+ })
|
|
|
+ ->order('a.addtime desc')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ 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,e.addr_code,"" 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)
|
|
|
+ ->leftJoin('addr e', 'e.id=a.addr_id AND e.is_del=' . CommonModel::$del_normal)
|
|
|
+ ->leftJoin('good f', 'f.id=a.good_id AND f.is_del=' . CommonModel::$del_normal)
|
|
|
+ ->where('a.is_del', CommonModel::$del_normal)
|
|
|
+ ->withAttr('addr_code', function ($val) {
|
|
|
+ return explode(',', $val);
|
|
|
+ })
|
|
|
+ ->withAttr('addr_name', function ($val, $da) {
|
|
|
+ $name = Db::name('area')
|
|
|
+ ->whereIn('code', $da['addr_code'])
|
|
|
+ ->column('name');
|
|
|
+ return implode($name);
|
|
|
+
|
|
|
+ })
|
|
|
+ ->findOrEmpty()
|
|
|
+ ->toArray();
|
|
|
+ return json_show(CommonModel::$success, '获取商品详情成功', $rs);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|