|
@@ -15,571 +15,6 @@ class Notify extends Api
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
- // 支付回调
|
|
|
- public function notify() {
|
|
|
-// require_once($_SERVER['DOCUMENT_ROOT'] . "/Plugins/WxPay/WxPay.php");
|
|
|
- $wxPay = new wxpay\WxPay();
|
|
|
- //验证是否是微信发送
|
|
|
- $flag = $wxPay->WxPayNotifyCheck();
|
|
|
-// error_log(print_r($flag, 1), 3, 'post.txt');
|
|
|
-
|
|
|
-// LL($flag,'./log1.txt');
|
|
|
- //验证成功
|
|
|
- if ($flag['status']) {
|
|
|
- if ($flag['data']['return_code'] == 'SUCCESS' && $flag['data']['result_code'] == 'SUCCESS') {
|
|
|
- $total_fee = trim($flag['data']['total_fee']) / 100; //支付的金额, 单位:分转成元
|
|
|
- $order_sn = trim($flag['data']['out_trade_no']);//商家订单号
|
|
|
-
|
|
|
- $PayResult = Db::name('rechar_order');
|
|
|
- $where['order_no'] = $order_sn;
|
|
|
- $order_info = $PayResult->where($where)->find();
|
|
|
- if ($order_info['money'] != $total_fee) {
|
|
|
- $r_arr['return_code'] = 'FAIL';
|
|
|
- $r_arr['return_msg'] = '回调失败';
|
|
|
- echo $wxPay->arrayToXml($r_arr);
|
|
|
- die;
|
|
|
- }
|
|
|
- if ($order_info['status'] == 1) {
|
|
|
- $r_arr['return_code'] = 'SUCCESS';
|
|
|
- $r_arr['return_msg'] = '回调成功';
|
|
|
- echo $wxPay->arrayToXml($r_arr);
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- //构建支付订单处理结果信息
|
|
|
- $_data['transaction_id'] = trim($flag['data']['transaction_id']); //微信交易凭证
|
|
|
- $_data['status'] = 1;
|
|
|
- $_data['updatetime'] = time();
|
|
|
-
|
|
|
- //支付订单类型
|
|
|
- if ($order_info['purpose'] == 1) {
|
|
|
- //查询订单
|
|
|
- $active_order = Db::name('game_people')->find($order_info['relation_id']);
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- //修改报名状态
|
|
|
- $active_order_rs = Db::name('game_people')->where(['id' => $order_info['relation_id'], 'status' => 0])->setField(['status' => 1, 'updatetime' => time()]);
|
|
|
-
|
|
|
- //活动标题
|
|
|
- $active_title = Db::name('game')->where(['id' => $active_order['game_id']])->value('name');
|
|
|
- //发送消息
|
|
|
- $data = [
|
|
|
- 'user_id' => $order_info['user_id'],
|
|
|
- 'type' => 1,
|
|
|
- 'title' => '比赛通知',
|
|
|
- 'content' => '您已成功报名' . $active_title . '比赛',
|
|
|
- 'createtime' => time()
|
|
|
- ];
|
|
|
- $sys_rs = Db::name('sys_msg')->insertGetId($data);
|
|
|
-
|
|
|
- if ($active_order_rs && $sys_rs) {
|
|
|
- Db::commit();
|
|
|
- } else {
|
|
|
- Db::rollback();
|
|
|
- $_data['pay_status'] = 1; //回调状态: 1=支付订单回调失败,2=充值回调失败,3=开通会员回调失败
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $PayResult->where($where)->setField($_data);
|
|
|
-
|
|
|
- $r_arr['return_code'] = 'SUCCESS';
|
|
|
- $r_arr['return_msg'] = '回调成功';
|
|
|
- echo $wxPay->arrayToXml($r_arr);
|
|
|
- die;
|
|
|
- }
|
|
|
- }
|
|
|
- $r_arr['return_code'] = 'FAIL';
|
|
|
- $r_arr['return_msg'] = '回调失败';
|
|
|
- echo $wxPay->arrayToXml($r_arr);
|
|
|
- file_put_contents('wx_pay_error_logs.txt', date('Y-m-d H:i:s').'支付失败!'.json_encode($flag), FILE_APPEND);
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 支付回调
|
|
|
- */
|
|
|
- public function notify1() {
|
|
|
- $paytype = $this->request->param('paytype');
|
|
|
- $pay = Service::checkNotify($paytype);
|
|
|
-// Log::record("=======================", 'info');
|
|
|
-// Log::record("pay:", 'info');
|
|
|
-// Log::record($pay, 'info');
|
|
|
-// Log::record("=======================", 'info');
|
|
|
- if (!$pay) {
|
|
|
- echo '签名错误';
|
|
|
- return;
|
|
|
- }
|
|
|
- $data = $pay->verify();
|
|
|
- $time = time();
|
|
|
- try {
|
|
|
- $payamount = $paytype == 'alipay' ? $data['total_amount'] : $data['total_fee'] / 100;
|
|
|
- $out_trade_no = $data['out_trade_no'];
|
|
|
- Db::startTrans();
|
|
|
- try{
|
|
|
- $orderModel = new \app\common\model\RecharOrder();
|
|
|
- $userModel = new \app\common\model\User();
|
|
|
- $orderInfo = $orderModel->where(["order_no"=>$out_trade_no])->find();
|
|
|
- $userInfo = $userModel->where(["id"=>$orderInfo["user_id"]])->find();
|
|
|
- $res1 = false;
|
|
|
- $res2 = false;
|
|
|
- $res3 = false;
|
|
|
- if($orderInfo['status'] == 0) {
|
|
|
- // 修改订单状态
|
|
|
- $res1 = $orderModel->update(["status"=>1,"updatetime"=>$time],["order_no"=>$out_trade_no, 'status' => 0]);
|
|
|
- // 充值后
|
|
|
- switch($orderInfo['purpose']) {
|
|
|
- case 1:
|
|
|
- // 修改用户为已缴纳认证费
|
|
|
- $userInfo->recharge_auth = 1;
|
|
|
- $res2 = $userInfo->save();
|
|
|
- $res3 = true;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- // 添加有眼缘记录--单次付费
|
|
|
- $data = [];
|
|
|
- $data['user_id'] = $userInfo->id;
|
|
|
- $data['fate_user_id'] = $orderInfo->fate_user_id;
|
|
|
- if(!\app\common\model\UserFate::where($data)->find()) {
|
|
|
- $data['createtime'] = $time;
|
|
|
- $res2 = \app\common\model\UserFate::insert($data);
|
|
|
- } else {
|
|
|
- $res2 = true;
|
|
|
- }
|
|
|
-
|
|
|
- // 返利
|
|
|
- $preuser_id = $userInfo->pre_user_id;
|
|
|
- if($userInfo->vip_duetime < $time) {
|
|
|
- $memo = '用户充值获得收益!';
|
|
|
- $profit = $payamount * config('site.userProfitRate') * 0.01;
|
|
|
- } else {
|
|
|
- $memo = '会员充值获得收益!';
|
|
|
- $profit = $payamount * config('site.vipProfitRate') * 0.01;
|
|
|
- }
|
|
|
- if($profit>=0.01 && $preuser_id > 0) {
|
|
|
- $res3 = \app\common\model\User::profit($profit,$preuser_id,$memo);
|
|
|
- } else {
|
|
|
- $res3 = true;
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- // 获取vip配置信息
|
|
|
- $vip_config_id = $orderInfo['vip_config_id'];
|
|
|
- $vipConfigInfo = \app\admin\model\vip\Config::where(['id'=>$vip_config_id])->find();
|
|
|
- // 计算vip到期时间
|
|
|
- if($userInfo->vip_duetime < $time) {
|
|
|
- $duetime = strtotime ( '+'.intval($vipConfigInfo['time']).' month' );
|
|
|
- } else {
|
|
|
- $duetime = strtotime ( '+'.intval($vipConfigInfo['time']).' month',$userInfo->vip_duetime);
|
|
|
- }
|
|
|
- // 修改用户为vip
|
|
|
- if($userInfo->vip_duetime <= time()) {
|
|
|
- $userInfo->view_count = $vipConfigInfo->give_times; // 今日剩余次数
|
|
|
- $userInfo->view_date = date('Y-m-d'); // 次数最后更新日期
|
|
|
- }
|
|
|
- $userInfo->vip_duetime = $duetime;
|
|
|
- $res2 = $userInfo->save();
|
|
|
- // 添加查看次数
|
|
|
- $data = [];
|
|
|
- $data['user_id'] = $userInfo->id;
|
|
|
- $data['end_date'] = date("Y-m-d",$duetime);
|
|
|
- $data['times'] = $vipConfigInfo->give_times;
|
|
|
- $data['createtime'] = time();
|
|
|
- $res3 = \app\common\model\GiveFateLog::insert($data);
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- // 获取钻石配置信息
|
|
|
- $vip_config_id = $orderInfo['vip_config_id'];
|
|
|
- $vipConfigInfo = Db::name('diamond')->where(['id'=>$vip_config_id])->find();
|
|
|
- //修改用户钻石余额
|
|
|
- $diamond = $userInfo['diamond'] + $vipConfigInfo['number'];
|
|
|
- $res2 = Db::name('user')->where(['id' => $userInfo['id'], 'diamond' => $userInfo['diamond']])->setField('diamond', $diamond);
|
|
|
- // 添加钻石明细
|
|
|
- $diamond_log = Db::name('user_diamond_log')->where(['user_id' => $userInfo['id']])->order('id', 'desc')->find();
|
|
|
- if (!$diamond_log && $userInfo['diamond'] > 0) {
|
|
|
- $res3 = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- if ($diamond_log && $diamond_log['after'] != $userInfo['diamond']) {
|
|
|
- $res3 = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- $data = [];
|
|
|
- $data['user_id'] = $userInfo['id'];
|
|
|
- $data['diamond'] = $vipConfigInfo['number'];
|
|
|
- $data['before'] = $userInfo['diamond'];
|
|
|
- $data['after'] = $diamond;
|
|
|
- $data['memo'] = '充值';
|
|
|
- $data['createtime'] = time();
|
|
|
-
|
|
|
- $res3 = Db::name('user_diamond_log')->insertGetId($data);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if($res1 && $res2 !== false && $res3) {
|
|
|
- Db::commit();
|
|
|
- } else {
|
|
|
- Db::rollback();
|
|
|
- }
|
|
|
- }catch (ValidateException $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
- } catch (PDOException $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
- } catch (Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- //你可以在此编写订单逻辑
|
|
|
- } catch (Exception $e) {
|
|
|
- }
|
|
|
- echo $pay->success();
|
|
|
- }
|
|
|
-
|
|
|
- //自动取消超时未支付的活动订单
|
|
|
- public function cancelorder() {
|
|
|
- set_time_limit(0);
|
|
|
-
|
|
|
- $where = array(
|
|
|
- 'status' => 0,
|
|
|
- 'createtime' => ['lt', time() - 1920], //32分钟之前
|
|
|
- );
|
|
|
- $active_order = Db::name('active_order');
|
|
|
- $list = $active_order->where($where)->limit(200)->select();
|
|
|
-
|
|
|
- if (!$list) {
|
|
|
- echo 'mei shu ju';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $active_people = Db::name('active_people');
|
|
|
- $active_people_modify = Db::name('active_people_modify');
|
|
|
- $active = Db::name('active');
|
|
|
-
|
|
|
- foreach ($list as &$v) {
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- //修改订单信息
|
|
|
- $rs = $active_order->where(['id' => $v['id'], 'status' => 0])->setField('status', 3);
|
|
|
- if (!$rs) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动人员
|
|
|
- $rt = $active_people->where(['order_id' => $v['id'], 'status' => 0])->setField(['status' => 3, 'modifystatus' => 0]);
|
|
|
- if (!$rt) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动人员修改记录
|
|
|
- $res = $active_people_modify->where(['order_id' => $v['id'], 'status' => 0])->setField('status', 2);
|
|
|
- if ($res === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //减少活动已报名人数
|
|
|
- $active_info = $active->find($v['active_id']);
|
|
|
- $currentperson = $active_info['currentperson'] - $v['number'];
|
|
|
- $active_rs = $active->where(['id' => $v['active_id'], 'currentperson' => $active_info['currentperson']])->setField('currentperson', $currentperson);
|
|
|
- if (!$active_rs) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- }
|
|
|
-
|
|
|
- echo 'wan bi';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- //消息推送 我报名参加活动的前一天会提前推送消息,时间 地点 及一些提醒
|
|
|
- public function sysmsg() {
|
|
|
- set_time_limit(0);
|
|
|
-
|
|
|
- $where = array(
|
|
|
- 'starttime' => ['elt', time() + 86400], //活动开始前一天
|
|
|
- 'msgstatus' => 0,
|
|
|
- 'status' => ['neq', 3]
|
|
|
- );
|
|
|
-
|
|
|
- $active = Db::name('active');
|
|
|
- $list = $active->where($where)->limit(200)->select();
|
|
|
-
|
|
|
- if (!$list) {
|
|
|
- echo 'mei shu ju';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- $active_order = Db::name('active_order');
|
|
|
- $sys_msg = Db::name('sys_msg'); //系统消息
|
|
|
-
|
|
|
- $data['type'] = 1;
|
|
|
- $data['title'] = '活动通知';
|
|
|
- $data['createtime'] = time();
|
|
|
- foreach ($list as &$v) {
|
|
|
- //修改活动消息通知状态
|
|
|
- $active->where(['id' => $v['id']])->setField('msgstatus', 1);
|
|
|
- //发送通知
|
|
|
- $data['content'] = '您报名的' . $v['title'] . '活动即将开始,请规划好您的时间。活动集合时间:' . date('Y-m-d H:i', $v['collectiontime']) . ',活动集合地点:' . $v['collectionplace'];
|
|
|
- //查询报名用户id
|
|
|
- $user_ids = $active_order->where(['active_id' => $v['id'], 'status' => 1])->column('user_id');
|
|
|
- if ($user_ids) {
|
|
|
- foreach ($user_ids as &$va) {
|
|
|
- $data['user_id'] = $va;
|
|
|
- $sys_msg->insertGetId($data);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- echo 'wan bi';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- //每年1月1重置免费次数
|
|
|
- public function resetfreenumber() {
|
|
|
- set_time_limit(0);
|
|
|
- //每年开始时间
|
|
|
- $time = strtotime(date('Y-1-1 0:0:0', time()));
|
|
|
-
|
|
|
- $where = array(
|
|
|
- 'freenumbertime' => ['lt', $time]
|
|
|
- );
|
|
|
-
|
|
|
- $user = Db::name('user');
|
|
|
- $list = $user->where($where)->limit(200)->select();
|
|
|
-
|
|
|
- if (!$list) {
|
|
|
- echo 'mei shu ju';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- $vip = Db::name('vip');
|
|
|
- foreach ($list as &$v) {
|
|
|
- $free = $vip->find($v['growthlevel']);
|
|
|
- $user->where(['id' => $v['id'], 'freenumber' => $v['freenumber']])->setField(['freenumber' => $free['free'], 'freenumbertime' => time()]);
|
|
|
- }
|
|
|
-
|
|
|
- echo 'wan bi';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- //自动结束已完成订单
|
|
|
- public function finishorder() {
|
|
|
- set_time_limit(0);
|
|
|
-
|
|
|
- $where = array(
|
|
|
- 'status' => 1,
|
|
|
- 'endtime' => ['lt', time()]
|
|
|
- );
|
|
|
-
|
|
|
- $active = Db::name('active');
|
|
|
- $list = $active->where($where)->limit(100)->select();
|
|
|
-
|
|
|
- if (!$list) {
|
|
|
- echo 'mei shu ju';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- $active_order = Db::name('active_order');
|
|
|
- $active_people = Db::name('active_people');
|
|
|
- $active_people_modify = Db::name('active_people_modify');
|
|
|
- $active_refund = Db::name('active_refund');
|
|
|
-
|
|
|
- foreach ($list as &$v) {
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- //活动结束
|
|
|
- $active_rs = $active->where(['id' => $v['id'], 'status' => 1])->setField(['status' => 2, 'updatetime' => time()]);
|
|
|
- if (!$active_rs) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动订单状态
|
|
|
- $order_rs = $active_order->where(['active_id' => $v['id'], 'status' => 1])->setField(['status' => 2, 'updatetime' => time()]);
|
|
|
- if ($order_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动人员状态
|
|
|
- $people_rs = $active_people->where(['active_id' => $v['id'], 'status' => 1])->setField(['status' => 2, 'modifystatus' => 0, 'updatetime' => time()]);
|
|
|
- if ($people_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动人员信息修改表
|
|
|
- $people_modify_rs = $active_people_modify->where(['active_id' => $v['id'], 'status' => 0])->setField(['status' => 2, 'updatetime' => time()]);
|
|
|
- if ($people_modify_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动申请取消表
|
|
|
- $refund_rs = $active_refund->where(['active_id' => $v['id'], 'status' => 0])->setField(['status' => 2, 'updatetime' => time()]);
|
|
|
- if ($refund_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- }
|
|
|
-
|
|
|
- echo 'wan bi';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- //自动取消未成行订单
|
|
|
- public function cancelminpeopleorder() {
|
|
|
- set_time_limit(0);
|
|
|
-
|
|
|
- $where = array(
|
|
|
- 'status' => 0,
|
|
|
- 'signupendtime' => ['lt', time()]
|
|
|
- );
|
|
|
-
|
|
|
- $active = Db::name('active');
|
|
|
- $list = $active->where($where)->limit(100)->select();
|
|
|
-
|
|
|
- if (!$list) {
|
|
|
- echo 'mei shu ju';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- $active_order = Db::name('active_order');
|
|
|
- $active_people = Db::name('active_people');
|
|
|
- $active_people_modify = Db::name('active_people_modify');
|
|
|
- $active_refund = Db::name('active_refund');
|
|
|
- $user_coupon = Db::name('user_coupon'); //用户优惠券表
|
|
|
- $sys_msg = Db::name('sys_msg'); //消息通知
|
|
|
-
|
|
|
- foreach ($list as &$v) {
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- //活动结束
|
|
|
- $active_rs = $active->where(['id' => $v['id'], 'status' => 0])->setField(['status' => 3, 'updatetime' => time()]);
|
|
|
- if (!$active_rs) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动人员状态
|
|
|
- $people_rs = $active_people->where(['active_id' => $v['id'], 'status' => 1])->setField(['status' => 3, 'modifystatus' => 0, 'updatetime' => time()]);
|
|
|
- if ($people_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动人员信息修改表
|
|
|
- $people_modify_rs = $active_people_modify->where(['active_id' => $v['id'], 'status' => 0])->setField(['status' => 2, 'updatetime' => time()]);
|
|
|
- if ($people_modify_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //修改活动申请取消表
|
|
|
- $refund_rs = $active_refund->where(['active_id' => $v['id'], 'status' => 0])->setField(['status' => 2, 'updatetime' => time()]);
|
|
|
- if ($refund_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //查询活动订单
|
|
|
- $active_order_list = $active_order->where(['active_id' => $v['id'], 'status' => 1])->select();
|
|
|
- if ($active_order_list) {
|
|
|
- //活动订单修改信息
|
|
|
- $order_data['status'] = 3; //状态:0=待付款,1=待出行,2=已完成,3=已取消
|
|
|
- $order_data['updatetime'] = time();
|
|
|
-
|
|
|
- foreach ($active_order_list as &$vv) {
|
|
|
- //退还支付金额
|
|
|
- if ($vv['price'] > 0) {
|
|
|
- $order_data['refundstatus'] = 1; //退款状态:0=无需退款,1=退款成功,2=退款失败
|
|
|
- $order_data['refundprice'] = $vv['price'];//退款金额
|
|
|
- $order_data['refundtime'] = time();
|
|
|
-
|
|
|
- if ($vv['paytype'] == 0) {
|
|
|
- //余额支付, 退回余额
|
|
|
- $rs = create_log($vv['price'], '活动取消返还', $vv['user_id'], 3, $vv['id']);
|
|
|
- if ($rs != 1) {
|
|
|
- $order_data['refundstatus'] = 2;
|
|
|
- }
|
|
|
- } elseif ($vv['paytype'] == 1) {
|
|
|
- //微信支付, 退回微信
|
|
|
- //扣除用户成长值
|
|
|
- $paygrowth = (int)config('site.paygrowth'); //每消费1元赠送成长值数量, 1元=?成长值
|
|
|
- $balance = floor($paygrowth * $vv['price']);
|
|
|
- if ($balance > 0) {
|
|
|
- $paygrowth_rs = create_growth_log(-$balance, '活动取消扣除', $vv['user_id'], 4, $vv['id']);
|
|
|
- }
|
|
|
- //退款单号
|
|
|
- $order_data['refund_no'] = $vv['order_sn'];
|
|
|
- //调用微信退款
|
|
|
- $wxData['transaction_id'] = $vv['transaction_id'];
|
|
|
- $wxData['out_refund_no'] = $order_data['refund_no'];
|
|
|
- $wxData['total_fee'] = (int)($vv['price'] * 100);//1 微信支付 单位为分
|
|
|
- $wxData['refund_fee'] = (int)($vv['price'] * 100);//1 微信支付 单位为分
|
|
|
- $wxData['refund_desc'] = '活动取消返还';
|
|
|
-// require_once("Plugins/WxPay/WxPay.php");
|
|
|
- $wxPay = new wxpay\WxPay(config('wxchatpay'));
|
|
|
- $back = $wxPay->WxPayRefund($wxData);
|
|
|
- if($back['return_code'] != 'SUCCESS' || $back['result_code'] != 'SUCCESS') {
|
|
|
- $order_data['refundstatus'] = 2;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //修改活动订单状态
|
|
|
- $order_rs = $active_order->where(['id' => $vv['id'], 'status' => 1])->setField($order_data);
|
|
|
- if ($order_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
- }
|
|
|
- //上级优惠券设为过期
|
|
|
- $user_coupon->where(['active_id' => $vv['id'], 'status' => 0])->setField('endtime', time() - 1);
|
|
|
- //发送消息
|
|
|
- $data = [
|
|
|
- 'user_id' => $vv['user_id'],
|
|
|
- 'type' => 1,
|
|
|
- 'title' => '活动通知',
|
|
|
- 'content' => '您报名的' . $v['title'] . '活动已取消',
|
|
|
- 'createtime' => time()
|
|
|
- ];
|
|
|
- $sys_msg->insertGetId($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- }
|
|
|
-
|
|
|
- echo 'wan bi';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- //自动上架活动
|
|
|
- public function showactive() {
|
|
|
- set_time_limit(0);
|
|
|
-
|
|
|
- $time = time();
|
|
|
- $where = array(
|
|
|
- 'showstatus' => 0,
|
|
|
- 'is_autoshow' => 1,
|
|
|
- 'showtime' => ['elt', $time]
|
|
|
- );
|
|
|
-
|
|
|
- $active = Db::name('active');
|
|
|
- $list = $active->where($where)->limit(200)->select();
|
|
|
-
|
|
|
- if (!$list) {
|
|
|
- echo 'mei shu ju';
|
|
|
- die;
|
|
|
- }
|
|
|
-
|
|
|
- foreach ($list as &$v) {
|
|
|
- $active->where(['id' => $v['id'], 'showstatus' => 0])->setField(['showstatus' => 1]);
|
|
|
- }
|
|
|
-
|
|
|
- echo 'wan bi';
|
|
|
- die;
|
|
|
- }
|
|
|
|
|
|
//视频转码
|
|
|
public function transcode() {
|