diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php
index a4ea0275..2e046b66 100644
--- a/api/controllers/plan/Plan.php
+++ b/api/controllers/plan/Plan.php
@@ -56,6 +56,7 @@ class Plan extends CI_Controller
$plan[] = array('url' => base_url(array('plan', 'syt', 'api_viewlog')), 'interval' => 5); //私域通直播间播放日志数据同步
$plan[] = array('url' => base_url(array('plan', 'syt', 'out_time')), 'interval' => 1); //订单过期
$plan[] = array('url' => base_url(array('plan', 'syt', 'union_user')), 'interval' => 1); //直播数据关联用户
+
$this->plan = $plan;
}
diff --git a/api/controllers/plan/Syt.php b/api/controllers/plan/Syt.php
index ad641120..0392aef3 100644
--- a/api/controllers/plan/Syt.php
+++ b/api/controllers/plan/Syt.php
@@ -45,13 +45,20 @@ class Syt extends CI_Controller
$res = $this->mdSytSubscribemsg->select($where, 'id asc', 1, 100);
$log = array();
if ($res) {
- $this->load->model('market/market_sylive_activity_model', 'mdSytActivity');
$wechatS = new WechatServer($this->options);
$wechatS->checkAuth();
+ $act_ids = implode(',',array_unique(array_column($res,'activityId')));
+ $act_rows = [];
+ if($act_ids){
+ $where = [
+ "activityId in ($act_ids)" => null
+ ];
+ $act_rows = $this->market_sylive_activity_model->map('activityId','',$where,'',0,0,'activityId,title');
+ }
foreach ($res as $key => $value) {
- $re_a = $this->mdSytActivity->get(array("activityId" => $value['a_id'], "status" => 0));
- if ($re_a) {
- $content = '您预约“' . $re_a['title'] . '”直播已经开始啦!赶紧进入直播间观看直播领取福利吧~';
+ $act = $act_rows['activityId'] ? $act_rows['activityId'][0] : [];
+ if ($act) {
+ $content = '您预约“' . $act['title'] . '”直播已经开始啦!赶紧进入直播间观看直播领取福利吧~';
$temp_arr = array(
'touser' => $value['openId'],
'template_id' => $value['templateId'],
@@ -69,6 +76,8 @@ class Syt extends CI_Controller
$log[] = $value['a_id'] . '=' . $value['openid'];
}
}
+ }else{
+ $this->mdSytSubscribemsg->update(['status' => -1], ['id' => $value['id']]);
}
}
}
@@ -260,7 +269,7 @@ class Syt extends CI_Controller
$where = [
'expireTime>' => 0,
'expireTime<' => time(),
- 'status' => 0
+ 'status' => 0,
];
$rows = $this->market_sylive_order_model->select($where,'id asc',1,20);
if($rows){
@@ -432,4 +441,34 @@ class Syt extends CI_Controller
}
echo '更新完成';
}
+
+ //更新经销商地址
+ public function tem_bizinfo(){
+ require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php';
+ $this->load->model('market/market_sylive_activity_bizinfo_model');
+ $file = FCPATH.'pdf/bizinfo.xlsx';
+ $reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档
+ $PHPExcel = $reader->load($file); // 文档名称
+ $objWorksheet = $PHPExcel->getActiveSheet();
+ $rowCnt = $objWorksheet->getHighestRow(); //获取总行数
+ for ($i = 2; $i <= $rowCnt; $i++) { //读取内容
+ $areaName = $objWorksheet->getCell('A' . $i)->getValue();
+ $bizName = $objWorksheet->getCell('B' . $i)->getValue();
+ $provinceName = $objWorksheet->getCell('C' . $i)->getValue();
+ $cityName = $objWorksheet->getCell('D' . $i)->getValue();
+ $addData = [
+ 'activityId' => 4,
+ 'areaName' => $areaName,
+ 'bizName' => $bizName,
+ 'provinceName' => $provinceName,
+ 'cityName' => $cityName,
+ ];
+ if(!$this->market_sylive_activity_bizinfo_model->count($addData)){
+ $addData['createTime'] = date('Y-m-d H:i:s');
+ $this->market_sylive_activity_bizinfo_model->add($addData);
+ }
+
+ }
+ echo '执行结束';
+ }
}
diff --git a/common/models/market/Market_sylive_activity_bizinfo_model.php b/common/models/market/Market_sylive_activity_bizinfo_model.php
new file mode 100644
index 00000000..5e94986f
--- /dev/null
+++ b/common/models/market/Market_sylive_activity_bizinfo_model.php
@@ -0,0 +1,11 @@
+table_name, 'default');
+ }
+}
\ No newline at end of file
diff --git a/home/controllers/h5/market/sylive/Act.php b/home/controllers/h5/market/sylive/Act.php
index f72d7c40..1e2387d7 100644
--- a/home/controllers/h5/market/sylive/Act.php
+++ b/home/controllers/h5/market/sylive/Act.php
@@ -115,17 +115,15 @@ class Act extends Wx {
}else{
$info['live_url'] = "https://live.haodian.cn/watch/{$row['channelId']}?userid={$userid}&ts={$ts}&sign={$sign}";
}
- //判断是否支付商品
- $is_pay = $this->market_sylive_order_model->count(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid]);
//微信分享
$wx_info = $this->share_info($row);
- $info['is_pay'] = $is_pay ? 1 : 0;
$info['show_code'] = $is_show_code ? 1 : 0;
$info['alert_code'] = $alert_code ? 1 : 0;
$this->data['info'] = $info;
$this->data['sign_package'] = $wx_info['sign_package'];
$this->data['share'] = $wx_info['share'];
$this->data['_title'] = $row['title'];
+ $this->data['skey'] = $info['skey'];
$this->show_view('h5/market/sylive/act/index');
}
@@ -293,9 +291,9 @@ class Act extends Wx {
}
$jsondata = json_decode($row['jsondata'],true);
$item = $jsondata['item'] ? $jsondata['item'] : [];
- $is_pay = $this->market_sylive_order_model->count(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid]);
+ $is_pay = $this->market_sylive_order_model->count(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid,'type'=>0]);
if($is_pay){
- $url = http_host_com('home').'/h5/market/sylive/act/ucenter?skey='.$skey;
+ $url = http_host_com('home').'/h5/market/sylive/ucenter/mygift?skey='.$skey;
redirect($url);exit;
}
$e_time = time() < strtotime($row['timeEnd']) ? strtotime($row['timeEnd']) - time() : 0;
@@ -346,7 +344,7 @@ class Act extends Wx {
$jsondata = json_decode($row['jsondata'],true);
$item = $jsondata['item'] ? $jsondata['item'] : [];
//判断是否已支付
- $o_row = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid]);
+ $o_row = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid,'type'=>0]);
if($o_row){
$this->show_json('',400,'已支付,请勿重复支付');
}
@@ -357,7 +355,7 @@ class Act extends Wx {
if($row['stock']<=0){
$this->show_json('',400,'已售罄');
}
- $unpay = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status'=>0,'userId'=>$this->uid,'expireTime>'=>time()]);
+ $unpay = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status'=>0,'userId'=>$this->uid,'expireTime>'=>time(),'type'=>0]);
if(!$unpay){
$mb_count = $redis_obj->sCard($mb_key); //获取集合中用户数量
if($mb_count && $mb_count>$row['stock']+10){
@@ -413,79 +411,6 @@ class Act extends Wx {
}
$this->show_json($result['data'],200,'操作成功');
}
- public function ucenter(){
- $skey = $this->input->get('skey');
- $param = $this->myencryption->base64url_decode($skey);
- $a_id = intval($param['a_id']);//活动id
- $row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
- if(!$row){
- throw new Hd_exception('参数错误',400);
- }
- $order = $this->market_sylive_order_model->get(['userId'=>$this->uid,'status'=>1,'itemId'=>$a_id]);
- if(!$order){
- $url = http_host_com('home').'/h5/market/sylive/act/item?skey='.$skey;
- redirect($url);exit;
- }
- $jsondata = json_decode($row['jsondata'],true);
- $item = $jsondata['item'] ? $jsondata['item'] : [];
- $validity = '';
- if($item['useTimeStart'] || $item['useTimeEnd']){
- $useTimeStart = date('Y-m-d',strtotime($item['useTimeStart']));
- $useTimeEnd = date('Y-m-d',strtotime($item['useTimeEnd']));
- $validity = "有效期 {$useTimeStart} - {$useTimeEnd}";
- }
- $order = [
- 'uname' => $order['uname'] ? $order['uname'] : '',
- 'utel' => $order['mobile'] ? $order['mobile'] : '',
- 'slogan' => '尊享您的直播好礼',
- 'valid_time' => $validity,
- 'oid' => $order['sid'],
- 'c_time' => date('Y-m-d H:i:s'),
- ];
- $if_pid = 0;
- $ac_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$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'];
- }
- $info = [
- 'bg' => "https://qs.haodian.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['introduction'] ? $item['introduction'] : '',
- 'order' => $order,
- 'skey' => $skey
- ];
- $this->data['info'] = $info;
- $this->data['_title'] = $row['title'];
- //微信分享
- $wx_info = $this->share_info($row);
- $this->data['sign_package'] = $wx_info['sign_package'];
- $this->data['share'] = $wx_info['share'];
- $this->show_view('h5/market/sylive/act/ucenter');
- }
//获取微信用户信息
public function userinfo(){
diff --git a/home/controllers/h5/market/sylive/Item.php b/home/controllers/h5/market/sylive/Item.php
new file mode 100644
index 00000000..bd827759
--- /dev/null
+++ b/home/controllers/h5/market/sylive/Item.php
@@ -0,0 +1,259 @@
+load->model('market/market_sylive_items_model');
+ $this->load->model('market/market_sylive_activity_model');
+ $this->load->model('market/market_sylive_order_model');
+ $this->load->model('market/market_sylive_activity_bizinfo_model','msa_bizinfo_model');
+ $this->load->library('market/sylive_entity');
+ }
+
+ public function detail(){
+ $itemId = $this->input->get('iid');
+ $skey = $this->input->get('skey');
+ $param = $this->myencryption->base64url_decode($skey);
+ $a_id = intval($param['a_id']);//活动id
+ $row = $this->market_sylive_items_model->get(['itemId'=>$itemId,'activityId'=>$a_id]);
+ if(!$row){
+ throw new Hd_exception('参数错误',400);
+ }
+ $imgs = json_decode($row['imgs'],true);
+ if($imgs['banner']){
+ $banner = [];
+ foreach ($imgs['banner'] as $item) {
+ $banner[] = build_qiniu_image_url($item);
+ }
+ }else{
+ $banner = $this->item_banner;
+ }
+ $e_time = time() < strtotime($row['timeEnd']) ? strtotime($row['timeEnd']) - time() : 0;
+ $s_time = time() < strtotime($row['timeStart']) ? strtotime($row['timeStart']) - time() : 0;
+ $is_pay = $this->market_sylive_order_model->count(['itemId'=>$itemId,'status'=>1,'userId'=>$this->uid,'type'=>0]);
+ if($is_pay){
+ $url = http_host_com('home').'/h5/market/sylive/ucenter?skey='.$skey;
+ redirect($url);exit;
+ }
+
+ $validity = '';
+ if($row['useStart']!='0000-00-00 00:00:00' || $row['useEnd']!='0000-00-00 00:00:00'){
+ $useTimeStart = date('Y-m-d',strtotime($row['useStart']));
+ $useTimeEnd = date('Y-m-d',strtotime($row['useEnd']));
+ $validity = "有效期 {$useTimeStart} - {$useTimeEnd}";
+ }
+ $title = $row['title'] ? $row['title'] : '';
+ $stock = $row['stock'];
+ $introduction = $row['descrip'] ? $row['descrip'] : '';
+ $price = $row['price'] ? $row['price'] : '';
+ //是否需要选择门店
+ $need_shop = 1;
+ $ac_user = $this->act_user_model->get(['id'=>$this->act_uid]);
+ if($ac_user['channelId']){
+ $channel_user = $this->act_user_model->get(['userId'=>$ac_user['channelId'],'activityId'=>$a_id]);
+ $channel_user['bizId'] && $need_shop = 0;
+ }
+ $need_shop = 1;
+ $biz_arr = $city_arr = $province_arr = [];
+ if($need_shop){
+ $province_arr = $this->msa_bizinfo_model->select(['status'=>0,'activityId'=>4],'',0,0,'distinct provinceName as name');
+ }
+ $info = [
+ 'itemId' => $row['itemId'],
+ 'title' => $title,
+ 's_time' => $s_time,
+ 'e_time' => $e_time,
+ 'price' => $price,
+ 'content' => $introduction,
+ 'banner' => $banner,
+ 'stock' => $stock,
+ 'skey' => $skey,
+ 'validity' => $validity,
+ 'introTitle' => '权益说明',
+ 'need_shop' => $need_shop,
+ ];
+ $this->data['province_arr'] = $province_arr;
+ $this->data['city_arr'] = $city_arr;
+ $this->data['biz_arr'] = $biz_arr;
+ $this->data['info'] = $info;
+ $this->data['_title'] = $row['title'];
+ //微信分享
+ $wx_info = $this->share_info($row);
+ $this->data['sign_package'] = $wx_info['sign_package'];
+ $this->data['share'] = $wx_info['share'];
+ $this->show_view('h5/market/sylive/item/detail');
+ }
+
+ //支付
+ public function post_pay(){
+ $redis = load_cache('redis');
+ $redis_obj = $redis->redis();
+ $skey = $this->input->post('skey');
+ $name = $this->input->post('name');
+ $mobile = $this->input->post('telPhone');
+ $code = $this->input->post('code');
+ $province = $this->input->post('province');
+ $city = $this->input->post('city');
+ $biz = $this->input->post('biz');
+ $itemId = $this->input->post('itemId');
+ $param = $this->myencryption->base64url_decode($skey);
+ $a_id = intval($param['a_id']);//活动id
+ $row = $this->market_sylive_items_model->get(['itemId'=>$itemId]);
+ if(!$row){
+ $this->show_json('',400,'参数错误');
+ }
+ if(time()< strtotime($row['timeStart'])){
+ $this->show_json('',400,'尚未开始');
+ }
+ if(time() > strtotime($row['timeEnd'])){
+ $this->show_json('',400,'活动已结束');
+ }
+ $mb_key = "SYLIVE_MEMBERS_ITEM_ID_{$itemId}"; //集合缓存key
+ $code_key = "sylive_item_code_{$this->uid}_{$mobile}";//验证码
+ if(!mobile_valid($mobile)){
+ $this->show_json('',400,'请输入正确手机号');
+ }
+ if(!$code || ($redis->get($code_key)!=$code)){
+ $this->show_json('',400,'请输入正确验证码');
+ }
+ //判断是否已支付
+ $o_row = $this->market_sylive_order_model->get(['itemId'=>$itemId,'status'=>1,'userId'=>$this->uid,'type'=>0]);
+ if($o_row){
+ $this->show_json('',400,'已支付,请勿重复支付');
+ }
+ $pay_price = $row['price'];
+ if($pay_price<=0){
+ $this->show_json('',400,'无需支付');
+ }
+ if($row['stock']<=0){
+ $this->show_json('',400,'已售罄');
+ }
+ $act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]);
+ $p_user = [];
+ $act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId']]);
+ $unpay = $this->market_sylive_order_model->get(['itemId'=>$itemId,'activityId'=>$a_id,'status'=>0,'userId'=>$this->uid,'expireTime>'=>time(),'type'=>0]);
+ if(!$unpay){
+ $mb_count = $redis_obj->sCard($mb_key); //获取集合中用户数量
+ if($mb_count && $mb_count>$row['stock']+10){
+ $mb = $redis_obj->sMembers($mb_key);
+ $this->show_json('',400,'已售罄:'.json_encode($mb,JSON_UNESCAPED_UNICODE));
+ }
+ try {
+ $province && $jsondata = ['biz'=>"{$province}-{$city}-{$biz}"];
+ $this->market_sylive_order_model->db->trans_begin();
+ //限购一件
+ $u_row = $this->market_sylive_order_model->get(['itemId'=>$itemId,'activityId'=>$a_id,'status>='=>0,'userId'=>$this->uid,'expireTime>'=>time(),]);
+ if($u_row){
+ throw new Exception('限购一件');
+ }
+ $this->load->helper('order');
+ $unpay = [
+ 'sid' => create_order_no('350200','market'),
+ 'activityId' => $a_id,
+ 'userId' => $this->uid,
+ 'itemId' => $itemId,
+ 'itemTitle' => $row['title'],
+ 'totalPrice' => $pay_price,
+ 'expireTime' => time()+5*60,//订单过期时间
+ 'createTime' => date('Y-m-d H:i:s')
+ ];
+ $name && $unpay['uname'] = $name;
+ $mobile && $unpay['mobile'] = $mobile;
+ $p_user['teamId'] && $unpay['cfrom'] = 1;
+ $p_user['areaId'] && $unpay['areaId'] = $p_user['areaId'];
+ $p_user['bizId'] && $unpay['bizId'] = $p_user['bizId'];
+ $p_user['userId'] && $unpay['cfUserId'] = $p_user['userId'];
+ $jsondata && $unpay['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
+ $oid = $this->market_sylive_order_model->add($unpay);
+ if(!is_numeric($oid)){
+ $this->market_sylive_order_model->db->trans_rollback();
+ throw new Exception('创建订单失败');
+ }
+ $this->market_sylive_items_model->update(['stock = stock-1' =>null],['itemId'=>$itemId,'stock>'=>0]);
+ $res = $this->market_sylive_items_model->db->affected_rows();
+ if(!$res){
+ throw new Exception('已售罄');
+ }
+ $this->market_sylive_order_model->db->trans_commit();
+ $redis_obj->sRem($mb_key,$this->uid); //删除集合
+ }catch (Exception $e){
+ $redis_obj->sRem($mb_key,$this->uid); //删除集合
+ $this->market_sylive_order_model->db->trans_rollback();
+ $this->show_json('',400,$e->getMessage());
+ }
+ }else{
+ $jsondata = json_decode($unpay['jsondata'],true);
+ $update = ['uname'=>$name,'mobile'=>$mobile];
+ if($province){
+ $jsondata['biz'] = "{$province}-{$city}-{$biz}";
+ $update['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
+ }
+ $this->market_sylive_order_model->update($update,['id'=>$unpay['id']]);
+ }
+ $user = $this->user_model->get(['userId'=>$this->uid]);
+ $notify_url = http_host_com('home').'/h5/market/sylive/notify/item';
+ $result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],['wx_type'=>'dc']);
+ if(!$result['code']){
+ $this->show_json('',400,$result['msg']);
+ }
+ //删除缓存
+ $redis->delete($code_key);
+ $data = [
+ 'wxjson' => $result['data'],
+ 'oid' => $unpay['id'],
+ ];
+ $this->show_json($data,200,'操作成功');
+ }
+
+ //获取验证码
+ public function get_code(){
+ $mobile = $this->input->post('mobile');
+ if(!mobile_valid($mobile)){
+ $this->show_json('',400,'请输入正确的手机号码');
+ }
+ $redis = &load_cache('redis');
+ $key = "sylive_item_code_{$this->uid}_{$mobile}";
+ if(!$redis->get($key)){
+ $this->load->helper('string');
+ $code = random_string('numeric', 4);
+ $redis->save($key, $code, 60*5);
+ $content = "【好店云】您的验证码为: {$code},请勿泄露于他人!";
+ echo $content;exit;
+ b2m_send_sms($mobile,$content);
+ }
+ $this->show_json('',200, '验证码已发送');
+ }
+
+ public function biz_info(){
+ $type = $this->input->get('type');
+ $p_name = $this->input->get('p_name');
+ $c_name = $this->input->get('c_name');
+ $where = [
+ 'status'=>0,
+ 'activityId'=>4,
+ ];
+ if($type=='city'){
+ $where['provinceName'] = $p_name;
+ $lists = $this->msa_bizinfo_model->select($where,'',0,0,'distinct cityName as name');
+ }elseif ($type=='biz'){
+ $where['provinceName'] = $p_name;
+ $where['cityName'] = $c_name;
+ $lists = $this->msa_bizinfo_model->select($where,'',0,0,'bizName as name');
+ }else{
+ $lists = $this->msa_bizinfo_model->select($where,'',0,0,'distinct provinceName as name');
+ }
+ $data = [
+ 'lists' => $lists
+ ];
+ $this->show_json($data,200);
+ }
+
+ public function agreement(){
+ $this->show_view('h5/market/sylive/item/agreement');
+ }
+}
diff --git a/home/controllers/h5/market/sylive/Notify.php b/home/controllers/h5/market/sylive/Notify.php
index 3f1c31b3..31b2b891 100644
--- a/home/controllers/h5/market/sylive/Notify.php
+++ b/home/controllers/h5/market/sylive/Notify.php
@@ -114,4 +114,48 @@ class Notify extends CI_Controller {
echo '
