| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- namespace addon\giftcard\model\order;
- use app\model\BaseModel;
- class GiftCardOrder extends BaseModel
- {
- public $order_status_list = [
- 'topay' => '待支付',
- 'complete' => '已完成',
- 'close' => '已关闭',
- ];
- public $pay_type = [
- 'ONLINE_PAY' => '在线支付',
- 'BALANCE' => '余额支付',
- 'OFFLINE_PAY' => '线下支付'
- ];
- /**
- * 获取支付方式
- */
- public function getPayType()
- {
- //获取订单基础的其他支付方式
- $pay_type = $this->pay_type;
- //获取当前所有在线支付方式
- $onlinepay = event('PayType', []);
- if (!empty($onlinepay)) {
- foreach ($onlinepay as $k => $v) {
- $pay_type[ $v[ 'pay_type' ] ] = $v[ 'pay_type_name' ];
- }
- }
- return $pay_type;
- }
- /**
- * 获取礼品卡订单信息
- * @param $condition
- * @param string $field
- * @return array
- */
- public function getOrderInfo($condition, $field = '*', $alias = '', $join = [])
- {
- $info = model('giftcard_order')->getInfo($condition, $field, $alias, $join);
- return $this->success($info);
- }
- /**
- * 获取礼品卡订单
- * @param $condition
- * @param string $field
- * @return array
- */
- public function getOrderSum($condition, $field = '*', $alias = '', $join = [])
- {
- $info = model('giftcard_order')->getSum($condition, $field, $alias, $join);
- return $this->success($info);
- }
- /**
- * 获取礼品卡订单列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @return array
- */
- public function getOrderList($condition = [], $field = '*', $order = '', $limit = null)
- {
- $list = model('giftcard_order')->getList($condition, $field, $order, '', '', '', $limit);
- return $this->success($list);
- }
- /**
- * 获取礼品卡订单分页列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getOrderPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = '', $join = [])
- {
- $list = model('giftcard_order')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- return $this->success($list);
- }
- /**
- * 订单详情分页列表
- * @param $params
- * @return array
- */
- public function getOrderDetailPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = '', $join = [])
- {
- $list = $this->getOrderPageList($condition, $page, $page_size, $order, $field, $alias, $join)[ 'data' ] ?? [];
- if (!empty($list[ 'list' ])) {
- $order_goods_model = new GiftCardOrderGoods();
- foreach ($list[ 'list' ] as $k => $v) {
- $item_condition = array (
- [ 'order_id', '=', $v[ 'order_id' ] ]
- );
- $order_goods_list = $order_goods_model->getOrderGoodsList($item_condition)[ 'data' ] ?? [];
- $v[ 'order_goods_list' ] = $order_goods_list;
- $list[ 'list' ][ $k ] = $this->tran($v);
- }
- }
- return $this->success($list);
- }
- /**
- * 订单详情
- * @param $params
- * @return array
- */
- public function getOrderDetail($params)
- {
- $order_id = $params[ 'order_id' ];
- $site_id = $params[ 'site_id' ];
- $member_id = $params[ 'member_id' ] ?? 0;
- $condition = array (
- [ 'go.order_id', '=', $order_id ]
- );
- if ($site_id > 0) $condition[] = [ 'go.site_id', '=', $site_id ];
- if ($member_id > 0) $condition[] = [ 'go.member_id', '=', $member_id ];
- $order_info = $this->getOrderInfo($condition, 'go.*,m.nickname,m.headimg,m.mobile', 'go', [
- [ 'member m', 'go.member_id=m.member_id', 'left' ]
- ])[ 'data' ] ?? [];
- if (empty($order_info))
- return $this->error();
- $order_goods_model = new GiftCardOrderGoods();
- $condition = array (
- [ 'order_id', '=', $order_id ]
- );
- if ($site_id > 0) $condition[] = [ 'site_id', '=', $site_id ];
- if ($member_id > 0) $condition[] = [ 'member_id', '=', $member_id ];
- $order_goods_list = $order_goods_model->getOrderGoodsList($condition)[ 'data' ] ?? [];
- if (empty($order_goods_list))
- return $this->error();
- $order_info[ 'order_goods_list' ] = $order_goods_list;
- $order_info = $this->tran($order_info);
- return $this->success($order_info);
- }
- /**
- * 数据字段转化翻译
- * @param $data
- */
- public function tran($data)
- {
- $order_status = $data[ 'order_status' ] ?? '';
- if (!empty($order_status)) {
- $data[ 'order_status_name' ] = $this->order_status_list[ $order_status ];
- }
- return $data;
- }
- }
|