292 lines
13 KiB
PHP
292 lines
13 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
require_once 'Common.php';
|
|
|
|
class Ucenter extends Wx{
|
|
|
|
private $a_id,$skey;
|
|
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->load->model('market/market_sylive_items_model');
|
|
$this->load->model('market/market_sylive_order_model');
|
|
$this->load->model('market/market_sylive_activity_model');
|
|
$this->load->model('market/market_sylive_checkdata_model');
|
|
$this->load->library('AliWuliu');
|
|
$this->load->library('market/sylive_entity');
|
|
$this->skey = $this->input->get('skey');
|
|
$param = $this->myencryption->base64url_decode($this->skey);
|
|
$this->a_id = intval($param['a_id']);//活动id
|
|
$this->data['skey'] = $this->skey;
|
|
}
|
|
|
|
public function index(){
|
|
$params = $this->input->get();
|
|
$row = $this->market_sylive_activity_model->get(['activityId'=>$this->a_id]);
|
|
if(!$row){
|
|
throw new Hd_exception('参数错误',400);
|
|
}
|
|
$jsondata = json_decode($row['jsondata'],true);
|
|
$lists = [];
|
|
|
|
$lists[] = ['title'=>'我的权益','url'=>"/h5/market/sylive2/ucenter/orders?skey={$params['skey']}"];
|
|
$lists[] = ['title'=>'我的抽奖','url'=>"/h5/market/sylive2/ucenter/win?skey={$params['skey']}"];
|
|
$lists[] = ['title'=>'我的秒杀','url'=>"/h5/market/sylive2/ucenter/orders?skey={$params['skey']}&type=1"];
|
|
$jsondata['serviceLink'] && $lists[] = ['title'=>'联系客服','url'=>$jsondata['serviceLink']];
|
|
|
|
$user = $this->user_model->get(['userId'=>$this->uid],'unionid,nickname,headimg');
|
|
$info = [
|
|
'title' => $user['nickname'],
|
|
'logo' => $user['headimg'],
|
|
'list' => $lists
|
|
];
|
|
$this->data['info'] = $info;
|
|
$this->data['params'] = $params;
|
|
$this->show_view('h5/market/sylive2/ucenter/index');
|
|
}
|
|
|
|
//我的抽奖
|
|
public function win(){
|
|
$this->show_view('h5/market/sylive2/ucenter/win');
|
|
}
|
|
|
|
public function ajax_win(){
|
|
$params = $this->input->get();
|
|
$page = $params['page'] ? $params['page'] : 1;
|
|
$size = $params['size'] ? $params['size'] : 20;
|
|
$where = [
|
|
'activityId' => $this->a_id,
|
|
'userId' => $this->uid,
|
|
'win' => 1,
|
|
'status' => 1
|
|
];
|
|
$total = $this->market_sylive_order_model->count($where);;
|
|
$lists = [];
|
|
if($total){
|
|
$this->load->model('market/Market_sylive_activity_draw_model', 'mdSyliveActivityDraw');
|
|
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $this->a_id]);
|
|
$winTypeAry = [];
|
|
if ($re_draw && $re_draw['winType']) {
|
|
$json_winType = json_decode($re_draw['winType'], true);
|
|
foreach ($json_winType as $v) {
|
|
$v['img'] && $v['img'] = build_qiniu_image_url($v['img']);
|
|
$winTypeAry[$v['id']] = ['img' => $v['img'], 'tag' => $v['tag'], 'title' => $v['title']];
|
|
}
|
|
}
|
|
$rows = $this->market_sylive_order_model->select($where,'id desc',$page,$size,'id,winType,winUseStatus');
|
|
$oids = implode(',',array_column($rows,'id'));
|
|
$oids&& $check_rows = $this->market_sylive_checkdata_model->map('cfId','jsondata',["cfId in ({$oids})"=>null,'type'=>1,'ifCheck'=>1],'id desc','','','cfId,jsondata');
|
|
foreach ($rows as $key => $val) {
|
|
$ck_jsondata = $check_rows[$val['id']] ? json_decode($check_rows[$val['id']],true) : [];
|
|
$winTypeItem = $winTypeAry[$val['winType']];
|
|
if($winTypeItem){
|
|
$lists[] = [
|
|
'id' => $val['id'],
|
|
'img' => $winTypeItem['img'],
|
|
'title' => $winTypeItem['tag'],
|
|
'goods' => $winTypeItem['title'],
|
|
'is_writeoff' => $val['winUseStatus']==2 ? 1 : 0,
|
|
'msg' => '* 在2024年3月31日前在当地门店选购派电科技直播间参奖车型,即可领取礼品!', //中奖礼品需提车后才能享受
|
|
'courierNo' => $ck_jsondata['courierNo']
|
|
];
|
|
}
|
|
}
|
|
}
|
|
$data = [
|
|
'total' => $total,
|
|
'lists' => $lists
|
|
];
|
|
$this->show_json($data,200);
|
|
}
|
|
//我的订单
|
|
public function orders(){
|
|
$this->show_view('h5/market/sylive2/ucenter/orders');
|
|
}
|
|
|
|
//订单详情
|
|
public function detail(){
|
|
$oid = $this->input->get('id');
|
|
$order = $this->market_sylive_order_model->get(['id'=>$oid,'userId' => $this->uid]);
|
|
if(!$order){
|
|
throw new Hd_exception('参数错误',400);
|
|
}
|
|
$item = $this->market_sylive_items_model->get(['itemId'=>$order['itemId']]);
|
|
$validity = '';
|
|
if($item['useStart'] || $item['useEnd']){
|
|
$useTimeStart = date('Y-m-d',strtotime($item['useStart']));
|
|
$useTimeEnd = date('Y-m-d',strtotime($item['useEnd']));
|
|
$validity = "有效期 {$useTimeStart} - {$useTimeEnd}";
|
|
}
|
|
$order_jsondata = json_decode($order['jsondata'],true);
|
|
$order = [
|
|
'id' => $order['id'],
|
|
'uname' => $order['uname'] ? $order['uname'] : '',
|
|
'utel' => $order['mobile'] ? $order['mobile'] : '',
|
|
'slogan' => '尊享购车节好礼',
|
|
'valid_time' => $validity,
|
|
'sid' => $order['sid'],
|
|
'c_time' => date('Y-m-d H:i:s'),
|
|
'region' => $order_jsondata['address']['region'] ? $order_jsondata['address']['region'] : '',
|
|
'detail' => $order_jsondata['address']['detail'] ? $order_jsondata['address']['detail'] : ''
|
|
];
|
|
$if_pid = 0;
|
|
$ac_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$this->a_id],'channelId');
|
|
$ac_user['channelId'] && $pid_user = $this->user_model->get(['userId'=>$ac_user['channelId']],'uname,organizationId,mobile,headimg');
|
|
$logo = $gw_tel = $gw_slogan = $gw_title = '';
|
|
if($ac_user['channelId'] && $pid_user['organizationId']>0){
|
|
$group_id = $this->sylive_entity->get_level($pid_user['organizationId']);
|
|
if($group_id==3){ //顾问
|
|
$if_pid = 1;
|
|
$where = [
|
|
"organizationId in (select parentId from lc_market_sylive_organization where organizationId={$pid_user['organizationId']})" => null
|
|
];
|
|
$org = $this->market_sylive_organization_model->get($where);
|
|
}elseif($group_id==2){ //店长
|
|
$if_pid = 1;
|
|
$where = [
|
|
"organizationId" => $pid_user['organizationId']
|
|
];
|
|
$org = $this->market_sylive_organization_model->get($where);
|
|
}
|
|
$gw_title = $pid_user['uname'];
|
|
$gw_slogan = $org['organizationName'];
|
|
$gw_tel = $pid_user['mobile'];
|
|
$logo = $pid_user['headimg'];
|
|
}
|
|
//获取物流信息
|
|
$check_row = $this->market_sylive_checkdata_model->select(['cfId'=>$order['id'],'type'=>0,'ifCheck'=>1],'id desc',1,1,'jsondata');
|
|
$check_row && $ck_jsondata = json_decode($check_row[0]['jsondata'],true);
|
|
$express = ['title'=>'','code'=>'','list'=>[]];
|
|
$show_express = 0;
|
|
if($ck_jsondata && $ck_jsondata['courierNo']){
|
|
$show_express = 1;
|
|
$express['code'] = $ck_jsondata['courierNo'];
|
|
$mobile_last = strlen($order['mobile'])>4 ? substr($order['mobile'],-4) : '1234';
|
|
$res = $this->aliwuliu->kdi("{$ck_jsondata['courierNo']}:$mobile_last");
|
|
if($res['code']){
|
|
$express['title'] = $res['result']['expName'];
|
|
$express['list'] = $res['result']['list'];
|
|
}
|
|
}
|
|
$info = [
|
|
'bg' => "https://qs.liche.cn/web/images/project/H5-ShiYu/mine-bg.jpg",
|
|
'logo' => $logo,
|
|
'if_pid' => $if_pid,
|
|
'title' => $gw_title,
|
|
'slogan' => $gw_slogan,
|
|
'cust_tel' => $gw_tel,
|
|
'introTitle' => '权益说明',
|
|
'content' => $item['descrip'] ? $item['descrip'] : '',
|
|
'order' => $order,
|
|
'skey' => $this->data['skey'],
|
|
'ifAddress' => $item['ifAddress'],
|
|
'is_writeoff' => $order['useStatus']==2 ? 1 : 0,
|
|
'show_express' => $show_express,
|
|
'express' => $express
|
|
];
|
|
$this->data['info'] = $info;
|
|
$this->show_view('h5/market/sylive2/ucenter/detail');
|
|
}
|
|
|
|
public function ajax_order(){
|
|
$params = $this->input->get();
|
|
$page = $params['page'] ? $params['page'] : 1;
|
|
$size = $params['size'] ? $params['size'] : 20;
|
|
$where = [
|
|
'activityId' => $this->a_id,
|
|
'userId' => $this->uid,
|
|
'status' => 1
|
|
];
|
|
$where['type'] = intval($params['type']) ? 1 : 0;
|
|
$total = $this->market_sylive_order_model->count($where);
|
|
$lists = [];
|
|
if($total){
|
|
$rows = $this->market_sylive_order_model->select($where,'id desc',$page,$size);
|
|
$item_ids = implode(',',array_unique(array_column($rows,'itemId')));
|
|
$item_rows = [];
|
|
if($item_ids){
|
|
$item_rows = $this->market_sylive_items_model->map('itemId','',["itemId in ({$item_ids})"=>null],'',0,0,'itemId,imgs');
|
|
}
|
|
$oids = implode(',',array_column($rows,'id'));
|
|
$oids&& $check_rows = $this->market_sylive_checkdata_model->map('cfId','jsondata',["cfId in ({$oids})"=>null,'type'=>0,'ifCheck'=>1],'id desc','','','cfId,jsondata');
|
|
foreach ($rows as $val) {
|
|
$item = $item_rows[$val['itemId']] ? $item_rows[$val['itemId']][0] : [];
|
|
$imgs = json_decode($item['imgs'],true);
|
|
$img = $imgs['banner'][0] ? build_qiniu_image_url($imgs['banner'][0]) : '';
|
|
$ck_jsondata = $check_rows[$val['id']] ? json_decode($check_rows[$val['id']],true) : [];
|
|
$lists[] = [
|
|
'id' => $val['id'],
|
|
'sid' => $val['sid'],
|
|
'img' => $img,
|
|
'title' => $val['itemTitle'],
|
|
'time' => date('Y.m.d H:i:s',strtotime($val['createTime'])),
|
|
'price' => $val['totalPrice'],
|
|
'url' => "/h5/market/sylive2/ucenter/detail?skey={$this->skey}&id={$val['id']}",
|
|
'is_writeoff' => $val['useStatus']==2 ? 1 : 0,
|
|
'courierNo' => $ck_jsondata['courierNo']
|
|
];
|
|
}
|
|
}
|
|
$data = [
|
|
'total' => $total,
|
|
'lists' => $lists
|
|
];
|
|
$this->show_json($data,200);
|
|
}
|
|
|
|
//修改地址
|
|
public function edit_address(){
|
|
$params = $this->input->post();
|
|
if(!$params['region']||!$params['address']){
|
|
$this->show_json([],400,'参数错误');
|
|
}
|
|
$order = $this->market_sylive_order_model->get(['userId'=>$this->uid,'status'=>1,'id'=>$params['id']]);
|
|
if(!$order){
|
|
$this->show_json([],400,'订单不存在');
|
|
}
|
|
$jsondata = json_decode($order['jsondata'],true);
|
|
$jsondata['address']['region'] = $params['region'];
|
|
$jsondata['address']['detail'] = $params['address'];
|
|
$update = [
|
|
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE)
|
|
];
|
|
$this->market_sylive_order_model->update($update,['id'=>$order['id']]);
|
|
$this->show_json([],200,'保存成功');
|
|
}
|
|
|
|
public function get_wuli(){
|
|
$id = $this->input->get('id');
|
|
$type = $this->input->get('type'); // 1中奖订单 0普通订单
|
|
$where = [
|
|
'id' => $id,
|
|
'userId' => $this->uid,
|
|
'status' => 1
|
|
];
|
|
$type && $where['win'] = 1;
|
|
$row = $this->market_sylive_order_model->get($where);
|
|
if(!$row){
|
|
$this->show_json('',400,'参数错误');
|
|
}
|
|
$list = [];
|
|
$title = '';
|
|
//获取物流信息
|
|
$check_row = $this->market_sylive_checkdata_model->select(['cfId'=>$row['id'],'type'=>$type?1:0,'ifCheck'=>1],'id desc',1,1,'jsondata');
|
|
$check_row && $ck_jsondata = json_decode($check_row[0]['jsondata'],true);
|
|
if($ck_jsondata['courierNo']){
|
|
$mobile_last = strlen($row['mobile'])>4 ? substr($row['mobile'],-4) : '1234';
|
|
$res = $this->aliwuliu->kdi("{$ck_jsondata['courierNo']}:$mobile_last");
|
|
if($res['code']){
|
|
$title = $res['result']['expName'];
|
|
$list = $res['result']['list'];
|
|
}
|
|
}
|
|
|
|
$data = [
|
|
'title' => $title,
|
|
'courierNo' => $ck_jsondata['courierNo'],
|
|
'list' => $list
|
|
];
|
|
$this->show_json($data,200);
|
|
}
|
|
}
|