317 lines
12 KiB
PHP
317 lines
12 KiB
PHP
<?php
|
||
|
||
namespace app\home\controller;
|
||
use think\facade\View;
|
||
use think\facade\Lang;
|
||
/**
|
||
* ============================================================================
|
||
* 联课教育商城系统
|
||
* ============================================================================
|
||
* 版权所有 2022 刻羽互动科技有限公司,并保留所有权利。
|
||
* 网站地址: http://www.o1h.cn
|
||
* ----------------------------------------------------------------------------
|
||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
|
||
* 不允许对程序代码以任何形式任何目的的再发布。
|
||
* ============================================================================
|
||
* 控制器
|
||
*/
|
||
class Memberpointorder extends BaseMember
|
||
{
|
||
public function initialize()
|
||
{
|
||
parent::initialize(); // TODO: Change the autogenerated stub
|
||
Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/memberpoints.lang.php');
|
||
}
|
||
|
||
|
||
public function index()
|
||
{
|
||
//兑换信息列表
|
||
/* $condition = array();
|
||
$condition[] = array('point_buyerid','=',session('member_id'));
|
||
|
||
$pointorder_model = model('pointorder');
|
||
$order_list = $pointorder_model->getPointorderList($condition, '*', 10, 0, 'point_orderid desc');
|
||
$order_idarr = array();
|
||
$order_listnew = array();
|
||
if (is_array($order_list) && count($order_list) > 0) {
|
||
foreach ($order_list as $k => $v) {
|
||
$order_listnew[$v['point_orderid']] = $v;
|
||
$order_idarr[] = $v['point_orderid'];
|
||
}
|
||
}
|
||
|
||
//查询兑换商品
|
||
if (is_array($order_idarr) && count($order_idarr) > 0) {
|
||
$prod_list = $pointorder_model->getPointordergoodsList(array(array('pointog_orderid','in',$order_idarr)));
|
||
if (is_array($prod_list) && count($prod_list) > 0) {
|
||
foreach ($prod_list as $v) {
|
||
if (isset($order_listnew[$v['pointog_orderid']])) {
|
||
$order_listnew[$v['pointog_orderid']]['prodlist'][] = $v;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//信息输出
|
||
View::assign('order_list', $order_listnew);
|
||
View::assign('show_page', $pointorder_model->page_info->render());
|
||
// 设置买家当前菜单
|
||
$this->setMemberCurMenu('member_pointorder');
|
||
// 设置买家当前栏目
|
||
$this->setMemberCurItem('orderlist');*/
|
||
|
||
|
||
$order_model = model('order');
|
||
|
||
//搜索
|
||
$condition = array();
|
||
$condition[]=array('buyer_id','=',session('member_id'));
|
||
|
||
$order_sn = input('param.order_sn');
|
||
if ($order_sn != '') {
|
||
$condition[]=array('order_sn','like','%'.$order_sn.'%');
|
||
}
|
||
$query_start_date = input('param.query_start_date');
|
||
$query_end_date = input('param.query_end_date');
|
||
$if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $query_start_date);
|
||
$if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $query_end_date);
|
||
$start_unixtime = $if_start_date ? strtotime($query_start_date) : null;
|
||
$end_unixtime = $if_end_date ? strtotime($query_end_date) : null;
|
||
|
||
if ($start_unixtime) {
|
||
$condition[] = array('add_time','>=', $start_unixtime);
|
||
}
|
||
if ($end_unixtime) {
|
||
$end_unixtime=$end_unixtime+86399;
|
||
$condition[] = array('add_time','<=', $end_unixtime);
|
||
}
|
||
$state_type = input('param.state_type');
|
||
if ($state_type != '') {
|
||
$condition[] = array('order_state','=',str_replace(
|
||
array('state_new', 'state_pay', 'state_send', 'state_success', 'state_noeval', 'state_cancel'), array(ORDER_STATE_NEW, ORDER_STATE_PAY, ORDER_STATE_SEND, ORDER_STATE_SUCCESS, ORDER_STATE_SUCCESS, ORDER_STATE_CANCEL),$state_type));
|
||
}
|
||
if ($state_type == 'state_noeval') {
|
||
$condition[]=array('evaluation_state','=',0);
|
||
$condition[] = array('refund_state','=',0);
|
||
$condition[]=array('order_state','=',ORDER_STATE_SUCCESS);
|
||
}
|
||
|
||
//回收站
|
||
$recycle = input('param.recycle');
|
||
if ($recycle) {
|
||
$condition[]=array('delete_state','=',1);
|
||
} else {
|
||
$condition[]=array('delete_state','=',0);
|
||
}
|
||
|
||
|
||
$order_list = $order_model->getOrderList($condition, 5, '*', 'order_id desc','', array('order_common','order_goods','ppintuanorder'));
|
||
View::assign('show_page', $order_model->page_info->render());
|
||
|
||
$refundreturn_model = model('refundreturn');
|
||
$order_list = $refundreturn_model->getGoodsRefundList($order_list);
|
||
|
||
//订单列表以支付单pay_sn分组显示
|
||
$order_group_list = array();
|
||
$order_pay_sn_array = array();
|
||
foreach ($order_list as $order_id => $order) {
|
||
//显示取消订单
|
||
$order['if_cancel'] = $order_model->getOrderOperateState('buyer_cancel', $order);
|
||
//显示退款取消订单
|
||
$order['if_refund_cancel'] = $order_model->getOrderOperateState('refund_cancel', $order);
|
||
//显示收货
|
||
$order['if_receive'] = $order_model->getOrderOperateState('receive', $order);
|
||
//显示锁定中
|
||
$order['if_lock'] = $order_model->getOrderOperateState('lock', $order);
|
||
//显示物流跟踪
|
||
$order['if_deliver'] = $order_model->getOrderOperateState('deliver', $order);
|
||
//显示评价
|
||
$order['if_evaluation'] = $order_model->getOrderOperateState('evaluation', $order);
|
||
//显示删除订单(放入回收站)
|
||
$order['if_delete'] = $order_model->getOrderOperateState('delete', $order);
|
||
//显示永久删除
|
||
$order['if_drop'] = $order_model->getOrderOperateState('drop', $order);
|
||
//显示还原订单
|
||
$order['if_restore'] = $order_model->getOrderOperateState('restore', $order);
|
||
|
||
foreach ($order['extend_order_goods'] as $value) {
|
||
$value['goods_type_cn'] = get_order_goodstype($value['goods_type']);
|
||
$value['goods_url'] = url('Goods/index', ['goods_id' => $value['goods_id']]);
|
||
if ($value['goods_type'] == 5) {
|
||
$order['zengpin_list'][] = $value;
|
||
} else {
|
||
$order['goods_list'][] = $value;
|
||
}
|
||
}
|
||
|
||
if (empty($order['zengpin_list'])) {
|
||
$order['goods_count'] = count($order['goods_list']);
|
||
} else {
|
||
$order['goods_count'] = count($order['goods_list']) + 1;
|
||
}
|
||
$order_group_list[$order['pay_sn']]['order_list'][] = $order;
|
||
|
||
//如果有在线支付且未付款的订单则显示合并付款链接
|
||
if ($order['order_state'] == ORDER_STATE_NEW) {
|
||
if (!isset($order_group_list[$order['pay_sn']]['pay_amount'])) {
|
||
$order_group_list[$order['pay_sn']]['pay_amount'] = 0;
|
||
}
|
||
$order_group_list[$order['pay_sn']]['pay_amount'] += $order['order_amount'] - $order['pd_amount'] - $order['rcb_amount'];
|
||
}
|
||
$order_group_list[$order['pay_sn']]['add_time'] = $order['add_time'];
|
||
|
||
//记录一下pay_sn,后面需要查询支付单表
|
||
$order_pay_sn_array[] = $order['pay_sn'];
|
||
}
|
||
|
||
//取得这些订单下的支付单列表
|
||
$condition = array();
|
||
$condition[] = array('pay_sn','in',array_unique($order_pay_sn_array));
|
||
$order_pay_list = $order_model->getOrderpayList($condition,'*','','pay_sn');
|
||
foreach ($order_group_list as $pay_sn => $pay_info) {
|
||
$order_group_list[$pay_sn]['pay_info'] = isset($order_pay_list[$pay_sn])?$order_pay_list[$pay_sn]:'';
|
||
}
|
||
|
||
View::assign('order_group_list', $order_group_list);
|
||
|
||
View::assign('order_pay_list', $order_pay_list);
|
||
|
||
//查询支付订单
|
||
$goods_model = model('goods');
|
||
$sn = [];
|
||
foreach ($order_pay_list as $val) {
|
||
if ($val['api_paystate'] == 1) {
|
||
$orderId = $order_model->getOrderInfo(['pay_sn' => $val['pay_sn']])['order_id'];
|
||
$goods_id = $order_model->getOrdergoodsInfo(['order_id' => $orderId])['goods_id'];
|
||
|
||
$goods = $goods_model->getGoodsInfo(['goods_id' => $goods_id]);
|
||
|
||
$sn[] = $goods;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
View::assign('sn', $sn);
|
||
|
||
|
||
//var_dump($order_pay_list);die;
|
||
/* 设置买家当前菜单 */
|
||
$this->setMemberCurMenu('member_order');
|
||
/* 设置买家当前栏目 */
|
||
if ($recycle) {
|
||
$this->setMemberCurItem('member_order_recycle');
|
||
} else {
|
||
$this->setMemberCurItem('member_order');
|
||
}
|
||
|
||
return View::fetch($this->template_dir.'index');
|
||
}
|
||
|
||
|
||
/**
|
||
* 取消兑换
|
||
*/
|
||
public function cancel_order()
|
||
{
|
||
$pointorder_model = model('pointorder');
|
||
//取消订单
|
||
$data = $pointorder_model->cancelPointorder(input('param.order_id'), session('member_id'));
|
||
if ($data['state']) {
|
||
ds_json_encode(10000,lang('member_pointorder_cancel_success'));
|
||
} else {
|
||
ds_json_encode(10001,$data['msg']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 确认收货
|
||
*/
|
||
public function receiving_order()
|
||
{
|
||
$data = model('pointorder')->receivingPointorder(input('param.order_id'));
|
||
if ($data['state']) {
|
||
ds_json_encode(10000,lang('member_pointorder_confirmreceiving_success'));
|
||
} else {
|
||
ds_json_encode(10001,$data['msg']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 兑换信息详细
|
||
*/
|
||
public function order_info()
|
||
{
|
||
$order_id = intval(input('order_id'));
|
||
if ($order_id <= 0) {
|
||
$this->error(lang('param_error'), url('Memberpointorder/index'));
|
||
}
|
||
$pointorder_model = model('pointorder');
|
||
//查询兑换订单信息
|
||
$where = array();
|
||
$where[] = array('point_orderid','=',$order_id);
|
||
$where[] = array('point_buyerid','=',session('member_id'));
|
||
$order_info = $pointorder_model->getPointorderInfo($where);
|
||
if (!$order_info) {
|
||
$this->error(lang('member_pointorder_record_error'), url('Memberpointorder/index'));
|
||
}
|
||
//获取订单状态
|
||
$pointorderstate_arr = $pointorder_model->getPointorderStateBySign();
|
||
View::assign('pointorderstate_arr', $pointorderstate_arr);
|
||
|
||
//查询兑换订单收货人地址
|
||
$orderaddress_info = $pointorder_model->getPointorderAddressInfo(array('pointoa_orderid' => $order_id));
|
||
View::assign('orderaddress_info', $orderaddress_info);
|
||
|
||
//兑换商品信息
|
||
$prod_list = $pointorder_model->getPointordergoodsList(array('pointog_orderid' => $order_id));
|
||
View::assign('prod_list', $prod_list);
|
||
|
||
//物流公司信息
|
||
if ($order_info['point_shipping_ecode'] != '') {
|
||
$data = model('express')->getExpressInfoByECode($order_info['point_shipping_ecode']);
|
||
if ($data['state']) {
|
||
$express_info = $data['data']['express_info'];
|
||
}
|
||
View::assign('express_info', $express_info);
|
||
}
|
||
|
||
View::assign('order_info', $order_info);
|
||
View::assign('left_show', 'order_view');
|
||
|
||
|
||
/* 设置买家当前菜单 */
|
||
$this->setMemberCurMenu('member_pointorder');
|
||
/* 设置买家当前栏目 */
|
||
$this->setMemberCurItem('order_info');
|
||
return View::fetch($this->template_dir.'member_pointorder_info');
|
||
}
|
||
|
||
/**
|
||
* 用户中心右边,小导航
|
||
*
|
||
* @param string $menu_type 导航类型
|
||
* @param string $menu_key 当前导航的menu_key
|
||
* @return
|
||
*/
|
||
public function getMemberItemList() {
|
||
$menu_array = array(
|
||
array(
|
||
'name' => 'orderlist',
|
||
'text' => lang('member_pointorder_list_title'),
|
||
'url' => url('Memberpointorder/index')
|
||
)
|
||
);
|
||
if (request()->action() == 'order_info') {
|
||
$menu_array = array(
|
||
array(
|
||
'name' => 'orderinfo',
|
||
'text' => lang('ds_member_path_pointorder_info'),
|
||
'url' => 'javascript:void(0)'
|
||
)
|
||
);
|
||
}
|
||
return $menu_array;
|
||
}
|
||
} |