123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace app\mobile\logic;
- use app\model\AccountModel;
- use app\model\AccountTokenModel;
- use app\model\CommonModel;
- use app\model\ServiceModel;
- use app\model\VideoModel;
- use think\Exception;
- use think\facade\Config;
- use think\facade\Db;
- use think\response\Json;
- class ServiceLogic extends BaseLogic
- {
- //列表
- public static function list(array $data = []): Json
- {
- $db = ServiceModel::where([
- 'is_del' => CommonModel::$del_normal,
- 'company_id' => self::$company_id,
- 'card_id' => self::$card_id,
- ]);
- $count = $db->count('id');
- $list = $db
- ->field('id,original_price,activity_price,title,activity_status')
- ->page($data['page'], $data['size'])
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- return json_show(CommonModel::$success, '获取服务列表成功', ['count' => $count, 'list' => $list]);
- }
- //详情
- public static function read(int $id = 0): Json
- {
- $info = ServiceModel::field('id,original_price,activity_price,title,content,starttime,endtime,expiretime,activity_status')
- ->where(['id' => $id, 'is_del' => CommonModel::$del_normal])
- ->findOrEmpty()
- ->toArray();
- return $info ? json_show(CommonModel::$success, '获取服务详情成功', $info) : json_show(CommonModel::$error_param, '服务为空');
- }
- //订单列表
- public static function list(array $data = []): Json
- {
- $db = OrderModel::alias('a')
- ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
- ->where(['a.is_del'=>CommonModel::$del_normal, 'a.uid' => self::$aid]);
- if ($data['status'] != '') $db->where('a.status', $data['status']);
- $count = $db->count('a.id');
- $list = $db
- ->field('a.id,a.orderCode,b.good_name,a.num,a.status,a.addtime,a.type,a.price,a.total_price')
- ->page($data['page'], $data['size'])
- ->order('a.id', 'desc')
- ->select()
- ->toArray();
- return json_show(CommonModel::$success, '获取订单列表成功', ['count' => $count, 'list' => $list]);
- }
- //订单详情
- public static function info(int $id = 0): Json
- {
- $rs = OrderModel::alias('a')
- ->field('a.id,a.orderCode,a.status,a.addtime,a.type,b.good_name,a.num,c.contactor,c.mobile,c.addr,c.addr_code,a.price,a.total_price,a.post_name,a.post_code,a.remark,"支付流水号" p')
- ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
- ->leftJoin('addr c', 'c.id=a.addr_id AND c.is_del=' . CommonModel::$del_normal)
- ->leftJoin('pay_info d', 'd.id=a.pay_info_id')
- ->where(['a.is_del' => CommonModel::$del_normal, 'a.id' => $id, 'a.uid' => self::$aid])
- ->withAttr('addr', function ($val, $da) {
- return $da['addr_code'] ? get_addr_name($da['addr_code']) . $val : $val;
- })
- ->findOrEmpty()
- ->toArray();
- return $rs ? json_show(CommonModel::$success, '获取订单详情成功', $rs) : json_show(CommonModel::$error_param, '该订单不存在');
- }
- }
|