Пример #1
0
 public function exam()
 {
     if (IS_POST) {
         if (!empty($_POST)) {
             $marks = 0;
             foreach ($_POST as $key => $answer) {
                 $ka = explode('_', $key);
                 $exam_answer = $this->model->where(array('exam_id' => $ka[1]))->getField('exam_answer');
                 if (strtolower($answer) == strtolower($exam_answer)) {
                     $marks += $this->model->where(array('exam_id' => $ka[1]))->getField('exam_score');
                 }
             }
             $res = M('Member')->where(array('member_id' => $this->mid))->setField('score', $marks);
             if ($marks >= MSC('min_pass_score')) {
                 $this->success('恭喜您通过了新手考试,现在可以接取任务啦.', U('Task/index'));
             } else {
                 $this->error('抱歉,没有及格哦.');
             }
         } else {
             $this->error('非法操作');
         }
     } elseif (IS_GET) {
         $list = $this->model->order('exam_sort desc')->select();
         $this->assign('list', $list);
         $this->assign('h3_text', '考试任务');
         $this->display();
     }
 }
Пример #2
0
 public function index()
 {
     $notice = MSC('weixin_adv_notice');
     $where = array('is_use' => 1);
     $order = 'ap_sort desc';
     $count = $this->model->where($where)->count();
     $page = new Page($count, $this->listRows);
     $list = $this->model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order($order)->select();
     $this->assign('notice', $notice);
     $this->assign('list', $list);
     $this->assign('page', $page->show());
     $this->display();
 }
Пример #3
0
 /**
  * 购物车
  */
 public function index()
 {
     if (IS_POST) {
     } elseif (IS_GET) {
         $list = $this->Cart->getList();
         if (get_distributor($this->mid)) {
             foreach ($list as $key => $val) {
                 $list[$key]['price'] = MSC('distributor_discount') * $val['price'];
             }
         }
         $this->list = $list;
         $this->display();
     }
 }
 public function ajaxHandleWithdraw()
 {
     if (IS_AJAX) {
         $id = intval($_POST['id']);
         $status = intval($_POST['status']);
         if ($id) {
             $data = $this->model->where(array('wd_id' => $id))->find();
             if ($data['status'] != 0) {
                 $result['code'] = 300;
                 die;
             }
             if ($status == 1) {
                 //同意提现
                 // 					D('Member')->where(array('member_id'=>$data['member_id'],'status'=>1))->setDec('frozen',$data['amount']);
                 //生成账单流水
                 $bill['member_id'] = $data['member_id'];
                 $bill['bill_log'] = '提现成功';
                 $bill['amount'] = $data['amount'];
                 $bill['balance'] = M('Member')->where(array('member_id' => $data['member_id']))->getField('predeposit');
                 $bill['addtime'] = NOW_TIME;
                 $bill['bill_type'] = -1;
             } elseif ($status == -1) {
                 //拒绝提现
                 D('Member')->where(array('member_id' => $data['member_id'], 'status' => 1))->setInc('point', $data['wd_amount'] * MSC('point_exchange_rate'));
                 // 					D('Member')->where(array('member_id'=>$data['member_id'],'status'=>1))->setInc('predeposit',$data['amount']);
                 // 					D('Member')->where(array('member_id'=>$data['member_id'],'status'=>1))->setDec('frozen',$data['amount']);
                 //生成账单流水
                 $bill['member_id'] = $data['member_id'];
                 $bill['bill_log'] = '提现失败';
                 $bill['amount'] = $data['amount'];
                 $bill['balance'] = M('Member')->where(array('member_id' => $data['member_id']))->getField('predeposit');
                 $bill['addtime'] = NOW_TIME;
                 $bill['bill_type'] = 2;
             }
             M('MemberBill')->add($bill);
             $res = $this->model->where(array('id' => $id))->setField('status', $status);
             if ($res) {
                 $result['code'] = 200;
             } else {
                 $result['code'] = 300;
             }
         } else {
             $result['code'] = 404;
         }
     } else {
         $result['code'] = 500;
     }
     echo json_encode($result);
 }
Пример #5
0
 public function index()
 {
     $where = array();
     $order_sn = str_rp(trim($_GET['order_sn']));
     if ($order_sn) {
         $where['order_sn'] = array('like', '%' . $order_sn . '%');
     }
     $where['addtime'] = array('lt', NOW_TIME - MSC('arbitrate_time') * 60 * 60);
     $where['handle_status'] = array('neq', -1);
     $count = $this->reportModel->where($where)->count();
     $page = new Page($count, 10);
     $list = $this->reportModel->relation(true)->where($where)->limit($page->firstRow . ',' . $page->listRows)->order('addtime desc')->select();
     $this->assign('list', $list);
     $this->assign('page', $page->show());
     $this->title = '申诉管理';
     $this->assign('search', $_GET);
     $this->display();
 }
Пример #6
0
 /**
  * 积分提现
  */
 public function withdraw()
 {
     if (IS_POST) {
         $amount = floatval($_POST['amount']);
         $account = str_rp($_POST['account'], 1);
         $reaccount = str_rp($_POST['reaccount'], 1);
         if ($account != $reaccount) {
             $this->error('两次输入的提现账号不同.');
         }
         if ($amount < MSC('withdraw_min_limit')) {
             $this->error('提现金额低于最低限额.');
         }
         $data['member_id'] = $this->mid;
         $data['wd_account'] = $account;
         $data['wd_amount'] = $amount;
         $data['wd_time'] = NOW_TIME;
         $data['wd_status'] = 0;
         //-1驳回0未处理1已处理
         $data['wd_remark'] = '会员积分提现';
         $log_content['time'] = NOW_TIME;
         $log_content['content'] = '会员进行积分提现操作请求.';
         $log[] = $log_content;
         $data['wd_log'] = serialize($log);
         $res = M('Withdraw')->add($data);
         if ($res) {
             $rc = M('Member')->where(array('member_id' => $this->mid))->setDec('point', $amount * MSC('point_exchange_rate'));
             if ($rc) {
                 //TODO:客服提现或者直接支付宝转账
                 $this->success('提现操作成功,请等待客服处理.');
             } else {
                 $this->error('提现失败.');
             }
         } else {
             $this->error('提现失败.');
         }
     }
 }
Пример #7
0
 public function bargain()
 {
     $model = M('BargainLog');
     $sn = trim($_GET['sn']);
     if (!empty($sn)) {
         $order = M('Order')->where(array('order_sn' => $sn, 'goods_type_id' => 3))->find();
         if (!empty($order)) {
             if ($order['order_state'] >= 4) {
                 $this->error('该订单已经进入返款阶段,无法再进行砍价.');
             }
             $log['goods_id'] = $order['goods_id'];
             $log['order_sn'] = $order['order_sn'];
             $log['member_id'] = $order['member_id'];
             $log['friend_id'] = $this->mid;
             $count = $model->where($log)->count();
             if ($count) {
                 $this->error('你已经砍过价了.');
             }
             if ($log['member_id'] == $this->mid) {
                 $rc = M('Member')->where(array('member_id' => $this->mid))->setDec('predeposit', MSC('self_bargain_cost'));
                 if ($rc) {
                     //写入流水账单
                     $predeposit = M('Member')->where(array('member_id' => $this->mid))->getField('predeposit');
                     $bill['member_id'] = $this->mid;
                     $bill['bill_log'] = '自砍一刀花费金币';
                     $bill['amount'] = MSC('self_bargain_cost');
                     $bill['balance'] = $predeposit;
                     $bill['addtime'] = NOW_TIME;
                     $bill['bill_type'] = -1;
                     M('MemberBill')->add($bill);
                 } else {
                     $this->error('自砍一刀失败啦.');
                 }
             }
             $log['bargain_time'] = NOW_TIME;
             $res = $model->add($log);
             if ($res) {
                 $this->success('恭喜你,砍价成功.');
             } else {
                 $this->error('砍价失败.');
             }
         }
     }
 }
Пример #8
0
 public function cancelOrder()
 {
     if (IS_AJAX) {
         $order_id = intval($_POST['order_id']);
         $where = array('order_id' => $order_id);
         $order = $this->model->relation(true)->where($where)->find();
         if ($order['order_state'] == 60) {
             json_return(300, '该订单已取消,请勿重复操作.');
             die;
         } elseif ($order['order_state'] == 50) {
             json_return(300, '该订单已完成,无法进行取消订单操作.');
             die;
         }
         if ($order['order_state'] > 10) {
             M('Member')->where(array('member_id' => $order['member_id']))->setInc('point', $order['order_amount'] * MSC('point_exchange_rate'));
             $this->model->where($where)->setField('order_state', 60);
         } elseif ($order['order_state'] == 10) {
             $this->model->where($where)->setField('order_state', 60);
         }
     }
 }
Пример #9
0
 public function cancelTask()
 {
     $where['order_sn'] = trim($_GET['sn']);
     $where['member_id'] = $thid->mid;
     $order = M('Order')->where($where)->find();
     if (!empty($order)) {
         if ($order['order_sn'] == -1) {
             $this->error('该订单正在申诉解决,无法进行任何操作');
         } elseif ($order['order_sn'] == 5) {
             $this->error('该订单已经完成,无法进行取消操作');
         } else {
             $res = M('Order')->where($where)->setField('order_state', -2);
             if ($res) {
                 M('Member')->where(array('member_id' => $this->mid))->setDec('predeposit', MSC('cancel_task_punish'));
                 $predeposit = M('Member')->where(array('member_id' => $this->mid))->getField('predeposit');
                 //写入流水账单
                 $bill['member_id'] = $this->mid;
                 $bill['bill_log'] = '取消任务扣除金币';
                 $bill['amount'] = MSC('cancel_task_punish');
                 $bill['balance'] = $predeposit;
                 $bill['addtime'] = NOW_TIME;
                 $bill['bill_type'] = -1;
                 M('MemberBill')->add($bill);
                 //返回库存
                 M('Goods')->where(array('goods_id' => $order['goods_id']))->setInc('goods_storage');
                 $this->success('订单取消成功,取消订单扣除您' . MSC('cancel_task_punish') . '金币');
             } else {
                 $this->error('订单取消失败.');
             }
         }
     } else {
         $this->error('没有找到相关信息');
     }
 }
Пример #10
0
 public function reserve()
 {
     if (!$this->mid) {
         // 			json_return(300,'请先登录.',array(),U('Login/index'));
         $this->error('请先登录', U('Login/index'));
     }
     $goods_id = intval($_POST['goods_id']);
     $spec_id = intval($_POST['spec_id']);
     $num = intval($_POST['num']);
     if ($num) {
         if ($spec_id) {
             $goods_id = M('GoodsSpec')->where(array('spec_id' => $spec_id))->getField('goods_id');
         }
         $goods = M('Goods')->where(array('goods_id' => $goods_id))->find();
         if (get_distributor($this->mid)) {
             $cdisc = MSC('distributor_discount');
         } else {
             $cdisc = 1;
         }
         $data['order_sn'] = order_sn();
         $data['member_id'] = $this->mid;
         $data['order_type'] = 2;
         $data['goods_amount'] = $cdisc * get_discount($num) * $num * $goods['goods_price'];
         $data['discount'] = 0;
         $data['order_amount'] = $data['goods_amount'] - $data['discount'];
         $data['order_state'] = 0;
         $data['add_time'] = NOW_TIME;
         $data['goods_id'] = $goods_id;
         $data['spec_id'] = $spec_id;
         $data['reserve_num'] = $num;
         $res = M('Reserve')->add($data);
         if ($res) {
             $this->success('预订成功', $_SERVER['HTTP_REFERER']);
             // 				json_return(200,'预订成功.');
         } else {
             $this->error('预订失败');
             // 				json_return(300,'预定失败.');
         }
     } else {
         $this->error('预订数量不能为空');
         json_return(300, '预订数量不能为空');
     }
 }
Пример #11
0
function sendSMS($phone, $content, $api_account = '', $api_password = '', $needstatus = 'true')
{
    $api_url = 'http://222.73.117.158/msg/HttpBatchSendSM';
    if (empty($api_account)) {
        $api_account = MSC('sms_api_account');
    }
    if (empty($api_password)) {
        $api_account = MSC('sms_api_password');
    }
    $postArr = array('account' => $api_account, 'pswd' => $api_password, 'msg' => $content, 'mobile' => $phone, 'needstatus' => $needstatus);
    $result = post_url($api_url, $postArr);
    $res = explode(',', $result);
    return $res;
}
Пример #12
0
 /**
  * 浏览收藏任务
  */
 public function browse()
 {
     if (IS_POST) {
         //计算所需价格
         $vip = vip_level($this->mid);
         $goods_o_price = intval($_POST['goods_o_price'] * 100) / 100;
         $tax_rate = MSC('tax_rate');
         $goods_storage = intval($_POST['goods_storage']);
         $freight = intval($_POST['freight'] * 100) / 100;
         $goods_min_num = intval($_POST['goods_min_num']);
         $goods_price = ($goods_o_price * $goods_min_num + $freight) * $tax_rate;
         $add_bounty = intval($_POST['add_bounty'] * 100) / 100;
         $amount = ($goods_o_price * $goods_min_num + $freight) * $goods_storage + $goods_price * $goods_storage + $add_bounty * $goods_storage;
         $option = $_POST['vip_select'];
         //vip服务
         if (intval($_POST['vip_service'])) {
             $data['limit_id'] = intval($_POST['limit_id']);
             if (!empty($option)) {
                 $vip_discount = get_vip_discount($vip);
                 if (is_array($option)) {
                     foreach ($option as $key => $val) {
                         $amount += M('VipOption')->where(array('option_id' => $val))->getField('option_price') * $goods_storage * $vip_discount;
                     }
                 }
             }
             if (intval($_POST['limit_id'])) {
                 $amount += M('GoodsLimit')->where(array('limit_id' => intval($_POST['limit_id']), 'status' => 1))->getField('price');
             }
             $data['add_comment'] = str_rp(trim($_POST['add_comment']));
         }
         //计划任务
         if (intval($_POST['plan']) && intval($_POST['plan_days']) && intval($_POST['plan_publish_num']) && intval($_POST['interval_time'])) {
             $plan_click = intval($_POST['plan_days']) * intval($_POST['plan_publish_num']);
             $amount += $plan_click * MSC('plan_cost');
         }
         //保存主图
         if (!empty($_POST['pic'])) {
             $data['goods_pic'] = $_POST['pic'][0];
         }
         //数据整合处理
         $data['seller_id'] = $this->mid;
         $data['goods_name'] = str_rp(trim($_POST['goods_name']));
         $data['goods_url'] = str_rp(trim($_POST['goods_url']));
         $data['goods_o_price'] = $goods_o_price;
         $data['goods_storage'] = $goods_storage;
         $data['goods_price'] = $goods_price;
         //$data['goods_price'] = $goods_price*(1-(MSC('website_bonus')/100));
         $data['goods_min_num'] = $goods_min_num;
         $data['freight'] = $freight;
         $data['goods_amount'] = $amount;
         $data['add_bounty'] = $add_bounty;
         $data['search_key'] = str_rp(trim($_POST['search_key']));
         $data['search_tip'] = str_rp(trim($_POST['search_tip']));
         $data['comment'] = str_rp(trim($_POST['comment']));
         $data['pf_id'] = intval($_POST['web_platform']);
         $data['web_platform'] = M('Platform')->where(array('pf_id' => $data['pf_id']))->getField('pf_name');
         $data['account_id'] = M('SellerAccount')->where(array('account_id' => intval($_POST['account_id']), 'seller_id' => $this->mid, 'status' => 1))->getField('account_id');
         $data['goods_type_id'] = 4;
         $data['pay_result'] = 10;
         $data['goods_status'] = 1;
         $data['add_time'] = NOW_TIME;
         $data['has_word'] = $_POST['zi'];
         $device_id = intval($_POST['device_id']);
         if ($device_id == 1) {
             $data['goods_device'] = '手机';
         } elseif ($device_id == 2) {
             $data['goods_device'] = '电脑';
         }
         //保存模板
         if (intval($_POST['save_temp'])) {
             $data['temp_name'] = str_rp(trim($_POST['temp_name']));
         }
         $res = $this->model->add($data);
         if ($res) {
             //图片保存(上传)
             if (!empty($_POST['pic'])) {
                 foreach ($_POST['pic'] as $key => $val) {
                     $pic[$key]['goods_id'] = $res;
                     $pic[$key]['pic'] = $val;
                     $pic[$key]['p_sort'] = 0;
                 }
                 $gpr = M('GoodsPic')->addAll($pic);
             }
             //计划任务
             if (intval($_POST['plan']) && intval($_POST['plan_days']) && intval($_POST['plan_publish_num']) && intval($_POST['interval_time'])) {
                 $plan_data['goods_id'] = $res;
                 $plan_data['plan_days'] = intval($_POST['plan_days']);
                 $plan_data['plan_publish_num'] = intval($_POST['plan_publish_num']);
                 $plan_data['plan_interval'] = intval($_POST['interval_time']) * 60;
                 $plan_data['plan_days_start'] = intval($_POST['hours']) * 60 * 60 + intval($_POST['minute']) * 60;
                 $rpd = M('PublishPlan')->add($plan_data);
             }
             //vip
             if (!empty($option)) {
                 if (is_array($option)) {
                     foreach ($option as $key => $val) {
                         $option_data['goods_id'] = $res;
                         $option_data['option_id'] = $val;
                         M('GoodsOption')->add($option_data);
                     }
                 }
             }
             $predeposit = M('Seller')->where(array('seller_id' => $this->mid))->getField('predeposit');
             if ($predeposit < $amount) {
                 $this->error('预存款不足,请进行充值', U('Member/recharge', array('price' => $amount - $predeposit)));
             } else {
                 $pay['predeposit'] = $predeposit - $amount;
                 $frozen = M('Seller')->where(array('seller_id' => $this->mid))->getField('frozen');
                 $pay['frozen'] = $frozen + $amount;
                 $result = M('Seller')->where(array('seller' => $this->mid))->save($pay);
                 $this->model->where(array('goods_id' => $res, 'seller_id' => $this->mid))->setInc('frozen_amount', $amount);
                 if ($result) {
                     $crs = $this->model->where(array('goods_id' => $res, 'seller_id' => $this->mid))->setField('pay_result', 20);
                     //生成账单日志
                     $data['order_sn'] = 'S2_' . order_sn();
                     $data['seller_id'] = $this->mid;
                     $data['buyer_name'] = get_seller_nickname($data['seller_id']);
                     $data['order_type'] = 2;
                     $data['payment_id'] = 0;
                     $data['payment_name'] = '预存款转入冻结款';
                     $data['payment_time'] = NOW_TIME;
                     $data['shipping_express_id'] = 0;
                     $data['goods_amount'] = price_format($amount);
                     $data['order_title'] = '任务id:' . $res . '冻结' . $data['goods_amount'] . '金币';
                     $data['discount'] = 0;
                     $data['order_amount'] = $data['goods_amount'] - $data['discount'];
                     $data['order_state'] = 10;
                     $data['add_time'] = NOW_TIME;
                     $rc = $this->orderModel->add($data);
                     if ($crs) {
                         $bill_data['seller_id'] = $this->mid;
                         $bill_data['bill_log'] = '发布浏览收藏任务,任务号:' . $res . '冻结' . $amount;
                         $bill_data['amount'] = $amount;
                         $bill_data['balance'] = $pay['predeposit'];
                         $bill_data['addtime'] = NOW_TIME;
                         $bill_data['bill_type'] = -2;
                         //冻结
                         M('SellerBill')->add($bill_data);
                     }
                 }
                 $this->success('发布任务成功');
             }
         } else {
             $this->error('发布任务失败');
         }
     } elseif (IS_GET) {
         $where['select_status'] = 1;
         $vip_option = $this->vipOptionModel->relation(true)->where($where)->order($this->order)->select();
         $platform = M('Platform')->order('pf_sort desc')->select();
         $map['temp_name'] = array('neq', '');
         $map['seller_id'] = $this->mid;
         $template = $this->model->where($map)->order('add_time desc')->select();
         $this->assign('template', $template);
         $this->assign('platform', $platform);
         $this->assign('vip_option', $vip_option);
         $this->h3_title = '浏览收藏任务';
         $this->display('publish');
     }
 }
Пример #13
0
 /**
  * 生成订单
  */
 public function creatOrder()
 {
     $addr_id = intval($_POST['addr_id']);
     $addr_info = M('MemberAddrs')->where(array('addr_id' => $addr_id))->find();
     $goods_list = M('OrderGoods')->where(array('order_id' => 0, 'member_id' => $this->mid))->select();
     if (!empty($addr_info)) {
         $data['order_sn'] = order_sn();
         $data['member_id'] = $this->mid;
         $data['buyer_name'] = get_member_nickname($this->mid);
         switch (trim($_POST['pay_type'])) {
             case 1:
                 $data['payment_name'] = 'alipay';
                 break;
             case 2:
                 $data['payment_name'] = 'bdpay';
                 break;
         }
         $data['shipping_fee'] = 0;
         $data['goods_amount'] = 0;
         $data['discount'] = 0;
         $data['order_amount'] = 0;
         if (empty($goods_list)) {
             $this->error('您还没有选择好商品哦.', U('Cart/index'));
         }
         foreach ($goods_list as $key => $val) {
             //计算价格同时清除购物车里的商品
             $Cart = new Cart();
             $Cart->delItem($val['goods_id']);
             $goods_price = M('Goods')->where(array('goods_id' => $val['goods_id']))->getField('goods_price');
             if (get_distributor($this->mid)) {
                 $goods_price = $goods_price * MSC('distributor_discount');
             }
             $data['goods_amount'] += $goods_price * $val['goods_num'];
             $data['discount'] += $data['goods_amount'] * (1 - get_discount($val['goods_num']));
             //冻结库存
             M('Goods')->where(array('goods_id' => $val['goods_id']))->setDec('goods_storage', $val['goods_num']);
             M('Goods')->where(array('goods_id' => $val['goods_id']))->setInc('goods_freez', $val['goods_num']);
         }
         $data['order_amount'] = $data['goods_amount'] - $data['discount'];
         $data['order_message'] = str_rp($_POST['order_message'], 1);
         $member = M('Member')->where(array('member_id' => $this->mid))->field('mobile,email')->find();
         $data['mobile'] = $member['mobile'];
         $data['email'] = $member['email'];
         $data['order_state'] = 10;
         $data['add_time'] = NOW_TIME;
         $order_id = M('Order')->add($data);
         if ($order_id) {
             //认领订单商品 已从购物车页面写入
             M('OrderGoods')->where(array('order_id' => 0, 'member_id' => $this->mid))->setField('order_id', $order_id);
             //生成物流地址
             $address_data['order_id'] = $order_id;
             $address_data['buyer_id'] = $this->mid;
             $address_data['true_name'] = $addr_info['name'];
             $address_data['prov_id'] = $addr_info['province_id'];
             $address_data['city_id'] = $addr_info['city_id'];
             $address_data['area_id'] = $addr_info['area_id'];
             $address_data['address'] = $addr_info['addr'];
             $address_data['zip_code'] = $addr_info['zip'];
             $address_data['mob_phone'] = $addr_info['mobile'];
             $address_data['add_time'] = NOW_TIME;
             M('OrderAddress')->add($address_data);
             //订单日志
             $log_data['order_id'] = $order_id;
             $log_data['order_state'] = get_order_state_name(10);
             $log_data['change_state'] = get_order_state_name(20);
             $log_data['state_info'] = '会员确认订单';
             $log_data['log_time'] = NOW_TIME;
             $log_data['operator'] = '会员';
             M('OrderLog')->add($log_data);
             //进行支付跳转
             switch (trim($_POST['pay_type'])) {
                 case 1:
                     $this->success('订单生成成功', U('Pay/alipay', array('order_sn' => $data['order_sn'])));
                     break;
                 case 2:
                     $this->success('订单生成成功', U('Pay/bdpay', array('order_sn' => $data['order_sn'])));
                     break;
             }
         }
     } else {
         $this->error('请选择收货地址');
     }
 }