public function queryAction()
 {
     $model = new \Think\Model();
     $brand_id = get_brand_id();
     $time = date('Y-m');
     $user_id = is_user_login();
     $time = I("time");
     if (empty($time)) {
         $start_month = I("start_month");
         if (empty($start_month)) {
             $this->error("请输入月份时间!");
         } else {
             $start_time = $start_month . "-01 00:00:00";
             $end_time = $start_month . "-31 23:59:59";
         }
     } else {
         $start_time = I("start_time");
         $end_time = I("end_time");
         if (empty($start_time)) {
             $this->error("请输入开始时间!");
         }
         if (empty($end_time)) {
             $this->error("请输入终止时间!");
         }
     }
     $ret = ChannelService::getInstance()->getStatistics($user_id, $start_time, $end_time);
     $this->ajaxReturn(array("status" => 1, "statistics" => $ret));
 }
 public function indexAction()
 {
     $model = M("BrandConfig");
     $config = $model->where(array("brand_id" => get_brand_id()))->find();
     $this->assign("config", $config);
     $this->display();
 }
Esempio n. 3
0
 public function loginAction($username = null, $password = null, $verifycode = null)
 {
     // session('[start]');
     //  if(!check_verify($verifycode)){
     //     $this->error('验证码输入错误!');
     //  }
     $model = M("User");
     $map['username'] = $username;
     $map['invalid'] = 1;
     $user = $model->where($map)->find();
     if (is_array($user)) {
         /* 验证用户密码 */
         if (ucenter_md5($password, C("MD5_SECRET_KEY")) === $user['password'] || $user['password'] == $password) {
             $extension = M("UserExtension")->find($user['id']);
             if ($extension['work_status'] == 1) {
                 $this->error('您已离职,不能再登陆系统!');
             }
             $this->updateLogin($user['id']);
             //更新用户登录信息
             userLoginSession($user);
             session('[destroy]');
             if ($user['club_id'] != 0 || get_brand_id() != 0) {
                 $this->success('登录成功!', U('Main/main'));
             } else {
                 $this->success('登录成功!', U('Main/teacher'));
             }
         } else {
             $this->error('密码错误!');
         }
     } else {
         $this->error('用户不存在!');
     }
 }
 private function avg($userid, $protential, $invit, $invit_success, $invit_come, $deal_num, $a_member, $b_member, $pre_sale, $sale, $transform, $type, $time)
 {
     //cal days
     $fd = $time . "-01";
     $ld = strtotime("{$fd} +1 month");
     $days = ($ld - strtotime($fd)) / (60 * 60 * 24);
     $protential_avg = round($protential / $days);
     $invit_avg = round($invit / $days);
     $invit_success_avg = round($invit_success / $days);
     $invit_come_avg = round($invit_come / $days);
     $deal_num_avg = round($deal_num / $days);
     $a_member_avg = round($a_member / $days);
     $b_member_avg = round($b_member / $days);
     $pre_sale_avg = round($pre_sale / $days);
     $sale_avg = round($sale / $days);
     $transform_avg = round($transform / $days);
     $dao = M("McPlanDayNew");
     $dao->where(array("type" => $type, "user_id" => $userid, "time" => array("between", "{$time}-01,{$time}-31")))->delete();
     $data = array("type" => $type, "brand_id" => get_brand_id(), "club_id" => get_club_id(), "user_id" => $userid, "protential" => $protential_avg, "invit" => $invit_avg, "invit_success" => $invit_success_avg, "invit_come" => $invit_come_avg, "deal_num" => $deal_num_avg, "a_member" => $a_member_avg, "b_member" => $b_member_avg, "pre_sale" => $pre_sale_avg, "sale" => $sale_avg, "transform" => $transform_avg);
     for ($i = 1; $i < $days; $i++) {
         $day = $time . "-" . str_pad($i, 2, "0", STR_PAD_LEFT);
         $data['time'] = $day;
         $dao->data($data)->add();
     }
     $day = $time . "-" . str_pad($days, 2, "0", STR_PAD_LEFT);
     $days = $days - 1;
     $data = array("type" => $type, "brand_id" => get_brand_id(), "club_id" => get_club_id(), "user_id" => $userid, "protential" => $protential - $protential_avg * $days, "invit" => $invit - $invit_avg * $days, "invit_success" => $invit_success - $invit_success_avg * $days, "invit_come" => $invit_come - $invit_come_avg * $days, "deal_num" => $deal_num - $deal_num_avg * $days, "a_member" => $a_member - $a_member_avg * $days, "b_member" => $b_member - $b_member_avg * $days, "pre_sale" => $pre_sale - $pre_sale_avg * $days, "sale" => $sale - $sale_avg * $days, "transform" => $transform - $transform_avg * $days);
     $data['time'] = $day;
     $dao->data($data)->add();
 }
 public function indexAction()
 {
     $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select();
     $this->assign("clubs", $clubs);
     $this->assign("action", U('Mc/Cardtype/getCardtype'));
     // $this->display("Cashier@Cardtype:index");
     $this->display();
 }
Esempio n. 6
0
 public function existAction()
 {
     $brand_id = get_brand_id();
     $model = M("MemberBasic");
     $member = $model->where(array("brand_id" => $brand_id, "name" => I("name"), "phone" => I("phone")))->find();
     if (!empty($member)) {
         $this->ajaxReturn(array("status" => 0, "id" => $member["id"]));
     } else {
         $this->ajaxReturn(array("status" => 1));
     }
 }
Esempio n. 7
0
 public function queryAction()
 {
     list($page, $sidx, $limit, $sord, $start) = getRequestParams();
     $filters = I("filters", '', '');
     $brand_id = get_brand_id();
     $club_id = get_club_id();
     $condition = array("club_id" => $club_id);
     $filters = json_decode($filters);
     if ($filters->groupOp == 'AND') {
         $rules = $filters->rules;
         foreach ($rules as $key => $value) {
             if ($value->field == "contract_number") {
                 $condition["contract_number"] = $value->data;
             }
             if ($value->field == "card_number") {
                 $member_ids = M("Card")->where(array("card_number" => $value->data))->field("group_concat( distinct member_id) as ids")->find();
                 if (!empty($member_ids)) {
                     $condition["member_id"] = array("in", $member_ids['ids']);
                 } else {
                     $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => "");
                     $this->ajaxReturn($response);
                 }
             }
             if ($value->field == "name") {
                 $member_ids = M("MemberBasic")->where(array("name" => $value->data))->field("group_concat( distinct id) as ids")->find();
                 if (!empty($member_ids)) {
                     $condition["member_id"] = array("in", $member_ids['ids']);
                 } else {
                     $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => "");
                     $this->ajaxReturn($response);
                 }
             }
             if ($value->field == "phone") {
                 $member_ids = M("MemberBasic")->where(array("phone" => $value->data))->field("group_concat( distinct id) as ids")->find();
                 if (!empty($member_ids)) {
                     $condition["member_id"] = array("in", $member_ids['ids']);
                 } else {
                     $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => "");
                     $this->ajaxReturn($response);
                 }
             }
         }
     }
     $model = D("PtContract");
     $count = $model->where($condition)->count();
     $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select();
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret);
     $this->ajaxReturn($response);
 }
Esempio n. 8
0
 public function getAllCards($member_id, $brand_id = null)
 {
     if (empty($brand_id)) {
         $brand_id = get_brand_id();
     }
     if (!empty($brand_id)) {
         return $this->where(array("member_id" => $member_id, "brand_id" => $brand_id, "status" => array("neq", 5)))->select();
     } else {
         return $this->where(array("member_id" => $member_id, "status" => array("neq", 5)))->select();
     }
 }
Esempio n. 9
0
 public function buyAction()
 {
     $member_id = I("member_id");
     $member = M("MemberBasic")->find(I("member_id"));
     if (empty($member)) {
         $this->error("member does not exist");
     }
     $use_recharge = I("use_recharge");
     $rules = array(array('pos', 'number', '请输入正确的pos金额!', 1), array('cash', 'number', '请输入正确的现金金额!', 1), array('check', 'number', '请输入正确的支票金额!', 1), array('network', 'number', '请输入正确的支票金额!', 1), array('netbank', 'number', '请输入正确的支票金额!', 1));
     $recharge = 0;
     if ($use_recharge == 1) {
         $recharge = $member['recharge'] > I("should_pay") ? I("should_pay") : $member['recharge'];
     }
     if ($use_recharge == 1 && $recharge != 0) {
         M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] - $recharge);
         $data = array("member_id" => $member_id, "value" => "-{$recharge}", "record_id" => is_user_login(), "description" => "购定金消费¥{$recharge},余额¥" . ($member['recharge'] - $recharge));
         $recharge_id = M("RechargeHistory")->data($data)->add();
     }
     $service = \Service\CService::factory("Financial");
     $mc_id = I("type") == 8 ? $member['pt_id'] : $member['mc_id'];
     $bill_id = $service->addBillProject(I("type"), 0, 0, $member_id, I("should_pay"), 0, get_brand_id(), is_user_login(), get_club_id(), $mc_id, I("description"));
     if (!$bill_id) {
         M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] + $recharge);
         if (isset($recharge_id)) {
             M("RechargeHistory")->delete($recharge_id);
         }
         $this->error($service->getError());
     }
     $ret = $service->pay($bill_id, 0, is_user_login(), get_brand_id(), I('description'), I("cash"), I("pos"), I("check"), I("check_num"), get_club_id(), $recharge, I("network"), I("netbank"));
     if (!$ret) {
         M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] + $recharge);
         if (isset($recharge_id)) {
             M("RechargeHistory")->delete($recharge_id);
         }
         M("BillProject")->delete($bill_id);
         $this->error($service->getError());
     }
     if (I("type") == 8) {
         M("MemberBasic")->where(array("id" => $member_id))->setInc("pt_book_price", I("should_pay"));
     }
     if (I("type") == 9) {
         M("MemberBasic")->where(array("id" => $member_id))->setInc("contract_book_price", I("should_pay"));
     }
     // if(!empty($reason))
     // {
     // 	  $contract = M("PtContract")->find($contract_id);
     // 	  $data=array("extension"=>json_encode($contract),"reason"=>$reason,"record_id"=>is_user_login(),"club_id"=>get_club_id(),"brand_id"=>get_brand_id(),"type"=>1,"status"=>0);
     // 	  M("Review")->data($data)->add();
     // }
     $this->success("购买成功!", U("Cashier/Book/printreceipts/id/{$ret}"));
 }
Esempio n. 10
0
 public function indexAction()
 {
     if (is_user_brand()) {
         $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->order("id desc")->select();
     } else {
         $permission = D("FinanceClub")->where(array("user_id" => is_user_login()))->relation(true)->select();
         $clubs = array();
         foreach ($permission as $key => $value) {
             $clubs[] = $value['club'];
         }
     }
     $this->assign("clubs", $clubs);
     $this->display();
 }
Esempio n. 11
0
 public function getNotice()
 {
     list($page, $sidx, $limit, $sord, $start) = getRequestParams();
     $brand_id = get_brand_id();
     $condition = array("brand_id" => $brand_id);
     $notice = $this->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select();
     $count = $this->where($condition)->count();
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $notice);
     return $response;
 }
Esempio n. 12
0
 public function getCardtypeAction()
 {
     list($page, $sidx, $limit, $sord, $start) = getRequestParams();
     $brand_id = get_brand_id();
     $can_sale_id = D("CardSaleclub")->getCanSaleCards();
     $model = D("CardType");
     $ids = array();
     foreach ($can_sale_id as $key => $value) {
         $ids[] = $value["id"];
     }
     $useclub = I("useclub");
     if (!empty($useclub) && $useclub != -1) {
         $can_use_id = D("CardUseclub")->getCanUseCards($useclub);
         $model = D("CardType");
         $uids = array();
         foreach ($can_use_id as $key => $value) {
             $uids[] = $value["id"];
         }
         $ids = array_intersect($ids, $uids);
     }
     $ids = implode(',', $ids);
     $condition = array("brand_id" => $brand_id, "id" => array("in", $ids));
     $category = I("category");
     if ($category != -1 && $category !== '') {
         $condition["category"] = $category;
     }
     $type = I("type");
     if ($type != -1 && $type !== '') {
         $condition["type"] = $type;
     }
     $name = I("name");
     if ($name != -1 && $name !== '') {
         $condition["name"] = array("like", "%{$name}%");
     }
     $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select();
     $count = $model->where($condition)->count();
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select();
     $peaktimes = M("PeakTime")->where(array("brand_id" => get_brand_id()))->field('id,peak_name')->select();
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret, "userdata" => array("clubs" => $clubs, "peaktimes" => $peaktimes));
     $this->ajaxReturn($response);
 }
Esempio n. 13
0
function getautocardnumber()
{
    $max_card = M("Card")->where(array("sale_club" => get_club_id(), "is_auto_create" => 1))->order("card_number desc")->find();
    if (empty($max_card)) {
        $card_number = get_club_id() . "000001";
    } else {
        $card_number = $max_card['card_number'] + 1;
    }
    $card_number = preg_replace("/4/", "5", $card_number);
    $cardModel = D("Card");
    while (true) {
        if ($cardModel->isExist($card_number, get_brand_id())) {
            $card_number += 1;
            $card_number = preg_replace("/4/", "5", $card_number);
        } else {
            break;
        }
    }
    return $card_number;
}
Esempio n. 14
0
 public function getAllCanUpgrade($old_card_start_time, $card_type_id, $brand_id = null)
 {
     $brand_id = empty($brand_id) ? get_brand_id() : $brand_id;
     $can_sale_id = D("CardSaleclub")->getCanSaleCards();
     $ids = "";
     foreach ($can_sale_id as $key => $value) {
         if ($value['id'] == $card_type_id) {
             continue;
         }
         if ($key != 0) {
             $ids .= ",";
         }
         $ids .= $value["id"];
     }
     $cardtype = $this->find($card_type_id);
     $price = $cardtype['price'];
     // $valid_time = $cardtype['valid_time'];
     // $valid_number=$cardtype['valid_number'];
     // $type=$cardtype['type'];
     $condition = array("price" => array("EGT", $price), "brand_id" => $brand_id, "id" => array("in", $ids));
     // if($type==1) //time
     // {
     //     $condition["valid_time"]=array("EGT",$valid_time);
     // }
     // else
     // {
     // }
     $ret = $this->where($condition)->select();
     $old_start_time = strtotime($old_card_start_time);
     $now = time();
     foreach ($ret as $key => $value) {
         $month = $value["valid_time"];
         $end_time = strtotime("+{$month} month", $old_start_time);
         if ($end_time <= $now) {
             unset($ret[$key]);
         }
     }
     return $ret;
 }
Esempio n. 15
0
 public function queryAction()
 {
     list($page, $sidx, $limit, $sord, $start) = getRequestParams();
     $model = D("Channel");
     $club_id = get_club_id();
     if ($club_id != 0) {
         $condition = array("club_id" => $club_id);
     } else {
         $condition = array("brand_id" => get_brand_id());
     }
     $search = I("_search");
     if (!empty($search)) {
         $condition = array_merge($condition, getOneSearchParams());
     }
     $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select();
     $count = $model->where($condition)->count();
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret);
     $this->ajaxReturn($response);
 }
 public function queryAction()
 {
     $model = new \Think\Model();
     $brand_id = get_brand_id();
     $time = date('Y-m');
     // $sql="select b.id, b.name,b.level,count(a.channel_id)  as protential,COALESCE(sum(a.is_member),0) as mcount from yoga_channel b left join yoga_member_basic a on b.brand_id=$brand_id  and a.channel_id!=0  and a.channel_id=b.id ";
     $user_id = I("user_id");
     if (!empty($user_id)) {
         // $sql.=" and a.recommend_id=$user_id";
     }
     $time = I("time");
     if (empty($time)) {
         $start_month = I("start_month");
         if (empty($start_month)) {
             $this->error("请输入月份时间!");
         } else {
             $start_time = $start_month . "-01 00:00:00";
             $end_time = $start_month . "-31 23:59:59";
             // $sql.=" and a.create_time>='{$start_time}' and a.create_time<='{$end_time}'";
         }
     } else {
         $start_time = I("start_time");
         $end_time = I("end_time");
         if (empty($start_time)) {
             $this->error("请输入开始时间!");
         }
         if (empty($end_time)) {
             $this->error("请输入终止时间!");
         }
         // $sql.=" and a.create_time>='{$start_time}' and a.create_time<='{$end_time}'";
     }
     // $sql .=" group by b.id order by protential desc";
     // $ret = $model->query($sql);
     $ret = ChannelService::getInstance()->getStatistics($user_id, $start_time, $end_time);
     $this->ajaxReturn(array("status" => 1, "statistics" => $ret));
 }
Esempio n. 17
0
 public function editAction($id, $card_number, $btype, $card_type_id, $present_day, $present_num, $price, $start_time, $end_time, $active_type, $desc, $free_rest, $free_trans, $mc_name)
 {
     $rules = array(array('id', 'require', '合同ID必须!', 1), array('card_number', 'require', '卡号必须!', 1), array('btype', array(0, 1), '类型不对!', 1, 'in'), array('card_type_id', 'number', '卡类型不对!', 1), array('present_day', 'number', '赠送天数需要为整数!', 1), array('present_num', 'number', '赠送次数需要为整数!', 1), array('price', 'number', '请输入正确的应付价格!', 1), array('active_type', array(0, 1, 2), '请选择开卡方式!', 1, 'in'));
     $bill = M("BillProject")->find($id);
     $model = D("Contract");
     if (!$model->validate($rules)->create()) {
         $this->error($model->getError());
     }
     if ($active_type != 2) {
         $rules = array(array('start_time', '/^\\d{4}-\\d{2}-\\d{2}$/', '请选择合同开始日期!', 1), array('end_time', '/^\\d{4}-\\d{2}-\\d{2}$/', '请选择合同结束日期!', 1));
         if (!$model->validate($rules)->create()) {
             $this->error($model->getError());
         }
     }
     $cardTypeModel = M("CardType");
     $cardType = $cardTypeModel->find($card_type_id);
     if (empty($cardType)) {
         $this->error("卡种不存在!");
     }
     $model = D("Contract");
     $original_contract = $model->find($bill['object_id']);
     $member_id = $original_contract['member_id'];
     $card_id = $original_contract['card_id'];
     $original_extension = json_encode($original_contract);
     if (empty($original_contract)) {
         $this->error("Error");
     }
     if ($original_contract['is_review'] == 1 && !is_user_brand()) {
         $this->error("此合同已审核,如需修改,请联系管理员! ");
     }
     if ($original_contract['is_review'] == 2) {
         $this->error("此合同已升级作废,如需修改请联系管理员!  ");
     }
     $cardModel = D("Card");
     if ($card_number != $original_contract['card_number']) {
         $c = $cardModel->getCard($card_number, get_brand_id());
         if (empty($c)) {
             //delete this card is no relate contract
             $count = $model->where("card_id=" . $original_contract['card_id'])->count();
             if ($count == 1) {
                 $card = $cardModel->find($original_contract['card_id']);
                 if (empty($card)) {
                     $card = array("card_number" => $card_number, "member_id" => $member_id, "brand_id" => get_brand_id());
                     $card_id = $cardModel->data($card)->add();
                 } else {
                     M("Card")->where("id=" . $original_contract['card_id'])->setField(array("card_number" => $card_number, "is_auto_create" => 0));
                 }
             } else {
                 $card = $cardModel->find($card_id);
                 unset($card['id']);
                 $card['create_time'] = getDbTime();
                 $card['update_time'] = getDbTime();
                 $card['card_number'] = $card_number;
                 $card_id = $cardModel->data($card)->add();
             }
         } else {
             if ($c['member_id'] != $member_id) {
                 $this->error("此卡已被占用!请输入其他卡号!");
             }
             $card_id = $c['id'];
         }
     }
     if (!$card_id) {
         $this->error("开卡失败,请稍后再试!");
     }
     if (I('active_type') == 2) {
         unset($model->start_time);
         unset($model->end_time);
     }
     $new_contract = $original_contract;
     $new_contract['card_id'] = $card_id;
     $new_contract['type'] = $btype;
     if ($original_contract['card_type_id'] != $card_type_id) {
         $new_contract['card_type_extension'] = json_encode($cardType);
     }
     $new_contract['card_type_id'] = $card_type_id;
     $new_contract['present_day'] = $present_day;
     $new_contract['present_num'] = $present_num;
     $new_contract['price'] = $price;
     $new_contract['start_time'] = $start_time;
     $new_contract['end_time'] = $end_time;
     $new_contract['active_type'] = $active_type;
     $new_contract['free_rest'] = $free_rest;
     $new_contract['free_trans'] = $free_trans;
     if ($original_contract['mc_id'] != $mc_name) {
         M("MemberBasic")->where("id={$member_id}")->setField(array("mc_id" => $mc_name));
         M("BillProject")->where("id={$id}")->setField(array("mc_id" => $mc_name));
     }
     $new_contract['mc_id'] = $mc_name;
     if (!empty($desc)) {
         $new_contract['description'] = $desc . ";" . $original_contract['description'];
     }
     $new_contract['total_num'] = $present_num + $cardType['valid_number'];
     $model->data($new_contract)->save();
     M("BillProject")->where("id={$id}")->setField(array("price" => $price));
     //review
     $reason = "合同修改";
     if (!empty($reason)) {
         $contract = M("Contract")->find($new_contract["id"]);
         $data = array("original_extension" => $original_extension, "extension" => json_encode($contract), "reason" => $reason, "record_id" => is_user_login(), "club_id" => get_club_id(), "brand_id" => get_brand_id(), "type" => 0, "status" => 0);
         M("Review")->data($data)->add();
     }
     $this->success("修改成功");
 }
Esempio n. 18
0
 public function showEditAction($id)
 {
     $this->checkPermission($id);
     //get roles
     $brand_user = M("User")->where(array("is_brand" => get_brand_id()))->find();
     //get roles
     $authGroupAccess = M("AuthGroupAccess");
     $group_ids = $authGroupAccess->where("uid=" . $brand_user['id'])->field("group_id")->select();
     $ids = array();
     foreach ($group_ids as $key => $value) {
         $ids[] = $value['group_id'];
     }
     // $map['id'] = array("in",$ids);
     $map['module'] = array("not in", "Brand,Shopkeeper");
     $groups = M("AuthGroup")->where($map)->field("id,title")->select();
     $this->assign("groups", $groups);
     $user = M("User")->find($id);
     $user_extension = M("UserExtension")->find($id);
     $employee = array_merge($user, $user_extension);
     $this->assign("employee", $employee);
     //当前的权限
     $group_ids = $authGroupAccess->where("uid=" . $id)->field("group_id")->select();
     $ids = array();
     foreach ($group_ids as $key => $value) {
         $ids[] = $value['group_id'];
     }
     $map['id'] = array("in", $ids);
     $map['module'] = array("neq", "Brand");
     $groups = M("AuthGroup")->where($map)->field("id")->select();
     $roles = array();
     foreach ($groups as $key => $value) {
         $roles[] = $value['id'];
     }
     $this->assign("roles", $roles);
     $this->display("showAdd");
 }
Esempio n. 19
0
 protected function checkPermission($employee_id, $brand_id = null)
 {
     $model = M("User");
     $club = $model->find($employee_id);
     $brand_id = empty($brand_id) ? get_brand_id() : $brand_id;
     if (empty($club)) {
         $this->error("员工不存在!");
     }
     if ($club['brand_id'] != $brand_id) {
         $this->error("无权操作此员工!");
     }
     if ($employee_id == is_user_login()) {
         $this->error("无权操作此员工!");
     }
     return $club;
 }
Esempio n. 20
0
        }
    }
    $sql_select = 'SELECT goods_sn FROM ' . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_id={$activity_id}";
    $joined_goods = $GLOBALS['db']->getCol($sql_select);
    $smarty->assign('joined_goods', $joined_goods);
    $smarty->assign('goods_list', $goods_list);
    $smarty->assign('goods_list_div', true);
    $smarty->assign('filter', $filter);
    $smarty->assign('activity_id', $activity_id);
    $res['response_action'] = 'search_service';
    $res['main'] = $smarty->fetch('spread_activity_div.htm');
    die($json->encode($res));
} elseif ($_REQUEST['act'] == 'set_privilege') {
    $privilege = mysql_real_escape_string($_REQUEST['privilege']);
    if ($privilege != '') {
        $brand_list = get_brand_id();
    }
} elseif ($_REQUEST['act'] == 'get_act_goods') {
    $act_id = intval($_REQUEST['act_id']);
    $res = array('req_msg' => true, 'code' => false);
    if ($act_id != 0) {
        $sql_select = 'SELECT g.goods_name,g.goods_sn FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' ga,' . $GLOBALS['ecs']->table('goods') . 'g ' . " WHERE ga.goods_sn=g.goods_sn AND ga.act_id={$act_id}";
        $goods_list = $GLOBALS['db']->getAll($sql_select);
        $sql_select = 'SELECT g.goods_name,gifts_num FROM ' . $GLOBALS['ecs']->table('spread_activity') . ' sa,' . $GLOBALS['ecs']->table('goods') . " g WHERE sa.gifts_sn=g.goods_sn AND sa.activity_id={$act_id}";
        $gifts_info = $GLOBALS['db']->getRow($sql_select);
        $res['message'] = '<table width=100% cellpadding=0 cellspacing=0>';
        if ($goods_list) {
            foreach ($goods_list as $val) {
                $res['message'] .= "<tr><td>{$val['goods_sn']}</td><td>{$val['goods_name']}</td></tr>";
            }
            $res['message'] .= "<tr><td colspan=2><font color=red>赠品:</font>{$gifts_info['goods_name']}   <font color=red>数量:{$gifts_info['gifts_num']}</font></td></tr></table>";
Esempio n. 21
0
     if (admin_priv('order_sheet', '', false)) {
         $sql_one = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('order_sheet') . ' WHERE status<2';
         $sql_select = 'SELECT o.order_sheet_id,o.goods_sn,o.goods_name,o.add_time,o.production_day,o.manufacturer,u.unit_name,o.quantity,a.user_name FROM ' . $GLOBALS['ecs']->table('order_sheet') . ' AS o LEFT JOIN' . $GLOBALS['ecs']->table('goods_unit') . ' AS u ON o.unit_id=u.unit_id LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . ' AS a ON o.add_admin=a.user_id' . ' WHERE o.status<2 ORDER BY add_time ASC';
         $act = 'order_sheet';
         $result = filter_page($sql_one, $sql_select, $act);
         $filter = $result['filter'];
         $order_sheet_list = $result['result'];
         foreach ($filter as $key => $val) {
             $smarty->assign($key, $val);
         }
         foreach ($order_sheet_list as &$val) {
             $val['add_time'] = date('Y-m-d', $val['add_time']);
             $val['production_day'] = date('Y-m-d', $val['production_day']);
         }
         $smarty->assign('order_sheet_list', $order_sheet_list);
         $smarty->assign('brand_list', get_brand_id());
         $smarty->assign('dst_script', 'storage');
         $smarty->assign('foot_page', $smarty->fetch('page_fragment.htm'));
         $smarty->assign('order_sheet_div', $smarty->fetch('order_sheet_div.htm'));
         $res['main'] = $smarty->fetch('order_sheet.htm');
         die($json->encode($res));
     }
 } elseif ($_REQUEST['act'] == 'add_order_sheet_done') {
     $goods_sn = mysql_real_escape_string($_REQUEST['goods_sn']);
     $goods_name = mysql_real_escape_string($_REQUEST['goods_name']);
     $production_day = strtotime($_REQUEST['production_day']);
     $manufacturer = mysql_real_escape_string($_REQUEST['manufacturer']);
     $quantity = intval($_REQUEST['quantity']);
     $unit_id = intval($_REQUEST['goods_unit']);
     $res = array('req_msg' => true, 'timeout' => 2000, 'code' => falsea, 'message' => '', 'btncontent' => false);
     if ($goods_sn != '' && $quantity != 0) {
Esempio n. 22
0
 public function delayAction()
 {
     $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select();
     $this->assign("clubs", $clubs);
     $delay_history = D("DelayHistory")->relation(true)->where(array("brand_id" => get_brand_id()))->order("id desc")->select();
     $this->assign("history", $delay_history);
     $this->display();
 }
Esempio n. 23
0
 public function getAllClubsName()
 {
     return $this->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select();
 }
Esempio n. 24
0
 public function rechargeNewAction($member_id, $cash, $pos, $check, $check_num, $network, $netbank, $discount)
 {
     $memberModel = M("MemberBasic");
     $member = $memberModel->find($member_id);
     if (empty($member)) {
         $this->error("User is not exist!");
     }
     $model = D("RechargeHistory");
     if (!$model->create()) {
         $this->error($model->getError());
     }
     $model->record_id = is_user_login();
     $model->member_id = $member_id;
     $value = I("cash") + I("check") + I("pos") + I("network") + I("netbank");
     $recharge = $member['recharge'] + $value;
     $model->value = $value;
     $model->discount = $discount;
     $model->value_real = $value;
     $model->description = "充值¥{$value},折扣{$discount},余额¥{$recharge}";
     $id = $model->add();
     $service = \Service\CService::factory("Financial");
     $bill_id = $service->addBillProject(7, 0, $id, $member_id, I("cash") + I("pos") + I("check") + I("network") + I("netbank"), 0, get_brand_id(), is_user_login(), get_club_id(), $member['mc_id'], I("description"), $discount);
     if (!$bill_id) {
         $this->error($service->getError());
     }
     $ret = $service->pay($bill_id, 0, is_user_login(), get_brand_id(), "充值¥{$value},折扣{$discount},余额¥{$recharge}" . I("description"), I("cash"), I("pos"), I("check"), I('check_num'), get_club_id(), 0, I("network"), I("netbank"));
     if (!$ret) {
         M("BillProject")->delete($bill_id);
         $this->error($service->getError());
     }
     $memberModel->where(array("id" => $member_id))->setField(array("recharge" => $recharge, "recharge_discount" => $discount));
     //       $cashModel = M("CashHistory");
     //       $cashModel->data(array("type"=>3,"cash"=>I("cash"),"check"=>I("check"),"pos"=> I("pos"),"object_id"=>$member_id,"price"=>0,"record_id"=>is_user_login(),"brand_id"=>get_brand_id(),"description"=>I("description"),"check_num"=>I('check_num')))->add();
     $this->ajaxReturn(array("status" => 1, "info" => "充值成功!", "recharge" => $recharge));
 }
Esempio n. 25
0
 $goods_id = intval(pq('input[name="id"]')->attr('value'));
 // 说明源id大于47900是无水印的 http://www.tomdurrie.com/search.php?page=380 前判读吧..
 // 63767 后面开始进行第二次采集
 if ($goods_id > 63767) {
     // 删除旧产品数据和相册数据
     delete('ecs_goods', array('goods_id' => $goods_id));
     delete('ecs_goods_gallery', array('goods_id' => $goods_id));
     $cat_name = trim(pq('#ur_here>.f_l>a:eq(1)')->html());
     $brand_name = trim(pq('.props>dl:eq(1)>dd')->html());
     $price_tmp = trim(pq('#ECS_SHOPPRICE')->html());
     if (preg_match('(\\d+)', $price_tmp, $match)) {
         $price = $match[0];
     } else {
         $price = 0;
     }
     $goods_info = array('goods_id' => $goods_id, 'cat_id' => get_cat_id($cat_name), 'goods_sn' => trim(pq('.props>dl:eq(0)>dd')->html()), 'goods_name' => trim(pq('h1')->html()), 'goods_desc' => '<table>' . pq('div>table')->html() . '</table>', 'brand_id' => get_brand_id($brand_name), 'goods_number' => 9999, 'market_price' => (int) floor($price / 0.57), 'shop_price' => $price, 'goods_thumb' => 'http://baobaopic.qiniudn.com/' . $v['thumb_img_org']);
     $result = insert('ecs_goods', $goods_info);
     /**
      * 获取相册
      * 
      */
     $gallerys_tmp = pq('.gallery>#demo>#demo1>ul>li');
     $goods_gallerys = array();
     foreach ($gallerys_tmp as $li) {
         $img_url = trim(pq($li)->find('a')->attr('rev'));
         $thumb_url = trim(pq($li)->find('img')->attr('src'));
         $goods_gallerys[] = array('goods_id' => $goods_id, 'img_url' => !empty($img_url) ? 'http://baobaopic.qiniudn.com/' . $img_url : '', 'thumb_url' => !empty($thumb_url) ? 'http://baobaopic.qiniudn.com/' . $thumb_url : '');
     }
     if (isset($goods_gallerys[0]['img_url']) && !empty($goods_gallerys[0]['img_url'])) {
         $gallery_result = insert_batch('ecs_goods_gallery', $goods_gallerys);
     }
 protected function edit()
 {
     $id = I("id");
     $rules = array(array('total', '/^\\d+(\\.\\d+)?$/', '请输入正确的项目总价!', 1), array('cash', '/^\\d+(\\.\\d+)?$/', '请输入正确的现金金额!', 1), array('pos', '/^\\d+(\\.\\d+)?$/', '请输入正确的POS金额!', 1), array('check', '/^\\d+(\\.\\d+)?$/', '请输入正确的支票金额!', 1), array('recharge', '/^\\d+(\\.\\d+)?$/', '请输入正确的储值卡金额!', 1));
     $model = D("PayHistory");
     if (!$model->validate($rules)->create()) {
         $this->error($model->getError());
     }
     $projectModel = M("BillProject");
     $pay_history = $model->relation(true)->find($id);
     $pay_history['member'] = M("MemberBasic")->find($pay_history['bill']['member_id']);
     $new_pay = $pay_history;
     $new_pay['cash'] = I("cash");
     $new_pay['pos'] = I("pos");
     $new_pay['check'] = I("check");
     $new_pay['recharge'] = I("recharge");
     $new_pay['network'] = I("network");
     $new_pay['netbank'] = I("netbank");
     $new_pay['create_time'] = I("create_time");
     $ret = $model->data($new_pay)->save();
     if ($ret === false) {
         $this->error($model->getError());
     }
     $paid = $pay_history['cash'] + $pay_history['pos'] + $pay_history['check'] + $pay_history['recharge'] + $pay_history['network'] + $pay_history['netbank'];
     $projectModel->where(array("id" => $pay_history['bill_project_id']))->setField("price", I("total"));
     $new_paid = I("cash") + I("pos") + I("check") + I("recharge");
     $interval = $new_paid - $paid;
     if ($pay_history['bill']['type'] == 7) {
         $ret = M("MemberBasic")->where(array("id" => $pay_history['bill']['member_id']))->setInc("recharge", $interval);
     } else {
         $ret = M("BillProject")->where(array("id" => $pay_history['bill_project_id']))->setInc("paid", $interval);
     }
     $reason = "修改消费记录";
     $new_pay['member'] = M("MemberBasic")->find($new_pay['bill']['member_id']);
     $new_pay['bill'] = M("BillProject")->find($pay_history['bill_project_id']);
     $data = array("original_extension" => json_encode($pay_history), 'extension' => json_encode($new_pay), "reason" => $reason, "record_id" => is_user_login(), "club_id" => get_club_id(), "brand_id" => get_brand_id(), "type" => 3, "status" => 0);
     M("Review")->data($data)->add();
     $response = array("success" => true, "message" => "success!", "new_id" => $id);
     $this->ajaxReturn($response);
 }
Esempio n. 27
0
 public function queryConsumeAction()
 {
     $service = \Service\CService::factory("Member");
     list($page, $sidx, $limit, $sord, $start) = getRequestParams();
     $condition = array("brand_id" => get_brand_id());
     $filters = I("filters", '', '');
     $filters = json_decode($filters);
     if ($filters->groupOp == 'AND') {
         $rules = $filters->rules;
         $name = "";
         $phone = "";
         foreach ($rules as $key => $value) {
             if ($value->field == "club_id" && $value->data != -1) {
                 $condition["club_id"] = $value->data;
             } else {
                 if ($value->field == "name") {
                     $name = $value->data;
                 } else {
                     if ($value->field == "phone") {
                         $phone = $value->data;
                     } else {
                         if ($value->field == "contract_number") {
                             $contract = M("Contract")->where(array("contract_number" => $value->data))->find();
                             if (empty($contract)) {
                                 $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null);
                                 $this->ajaxReturn($response);
                             }
                             $condition["contract_id"] = $contract['id'];
                         } else {
                             if ($value->field == "card_number") {
                                 $card = M("Card")->where(array("card_number" => $value->data))->find();
                                 if (empty($card)) {
                                     $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null);
                                     $this->ajaxReturn($response);
                                 }
                                 $condition["card_id"] = $card['id'];
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($name) || !empty($phone)) {
             $members = $service->getMemberByBrand(get_brand_id(), $name, $phone);
             if (empty($members)) {
                 $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null);
                 $this->ajaxReturn($response);
             }
             $ids = "";
             foreach ($members as $k => $v) {
                 if ($k != 0) {
                     $ids .= ",";
                 }
                 $ids .= $v['id'];
             }
             $condition["member_id"] = array("in", $ids);
         }
     }
     $model = D("CheckHistory");
     $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select();
     $count = $model->where($condition)->count();
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret);
     $this->ajaxReturn($response);
 }
Esempio n. 28
0
 public function doPayAction()
 {
     $goodsModel = M("Goods");
     $goodsModel->startTrans();
     $service = \Service\CService::factory("Financial");
     $bill_project = M("BillProject")->find(I("id"));
     if (empty($bill_project)) {
         $goodsModel->rollback();
         $this->error("Bill is not exist!");
     }
     $recharge = 0;
     $member_id = I("member_id");
     $member = M("MemberBasic")->find(I("member_id"));
     $price = $bill_project['price'] - $bill_project['paid'];
     if (I('use_recharge') == 1) {
         $recharge = $member['recharge'];
         $recharge = $recharge > $price ? $price : $recharge;
     }
     $ret = $service->pay(I("id"), 1, is_user_login(), get_brand_id(), I("description"), I("cash"), I("pos"), I("check"), I('check_num'), get_club_id(), $recharge, I("network"), I("netbank"));
     if (!$ret) {
         $goodsModel->rollback();
         $this->error($service->getError());
     }
     if (I('use_recharge') == 1 && $recharge > 0) {
         M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] - $recharge);
         $data = array("member_id" => $member_id, "value" => "-{$recharge}", "record_id" => is_user_login(), "description" => "支付购物欠款,余额" . ($member['recharge'] - $recharge));
         M("RechargeHistory")->data($data)->add();
     }
     $goodsModel->commit();
     $this->success("支付成功", U("printreceipts", array("id" => $ret)));
 }
Esempio n. 29
0
 public function indexAction()
 {
     $this->setIndexActiveClass();
     $id = I("id");
     $this->assign("edit", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "index");
     $this->assign("exist", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "exist");
     $this->assign("queryRecommend", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "queryRecommend");
     $this->assign("action", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "add");
     if (!empty($id)) {
         $this->assign("action", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "edit");
         $model = D("MemberBasic");
         $member = $model->find($id);
         if (!is_user_brand()) {
             $is_reception = D("User")->isReception(is_user_login());
             if (!$is_reception && $member["mc_id"] != is_user_login() && $member['record_id'] != is_user_login() && $member["pt_id"] != is_user_login()) {
                 $this->error("无权查看此用户信息");
             }
         } else {
             if ($member['brand_id'] != get_brand_id()) {
                 $this->error("无权查看此用户信息");
             }
         }
         // $mc
         $this->assign("member", $member);
     }
     $model = M("Channel");
     $channles = $this->getchannels();
     $this->assign("channels", $channles);
     if ((D("User")->isMc(is_user_login()) || D("User")->isPt(is_user_login())) && empty($id) && MODULE_NAME != 'Reception') {
         // $mcs=array( D("UserExtension")->find(is_user_login()));
         $mcs = D("User")->getMc();
     } else {
         $mcs = D("User")->getMc();
     }
     $this->assign("mcs", $mcs);
     // $brand_id=get_brand_id();
     // $users= $model->where("a.id=b.id and a.id=c.uid and b.brand_id=$brand_id and c.group_id=18")->table(array("yoga_user_extension"=>"a","yoga_user"=>"b","yoga_auth_group_access"=>"c"))->field("a.id,a.name_cn")->select();
     //    $this->assign("users",$users);
     $model = M("Club");
     $clubs = $model->where(array("brand_id" => get_brand_id()))->field("id,club_name")->select();
     $model = D("CardSaleclub");
     $types = $model->getCanSaleCards();
     $this->assign("types", $types);
     $this->assign("clubs", $clubs);
     // $mcs= $model->where("a.id=b.id and a.id=c.uid and b.brand_id=$brand_id and c.group_id=6")->table(array("yoga_user_extension"=>"a","yoga_user"=>"b","yoga_auth_group_access"=>"c"))->field("a.id,a.name_cn")->select();
     // $this->assign("mcs",$mcs);
     $this->display("Mc@Visit:index");
 }
Esempio n. 30
0
 public function queryAction()
 {
     $page = I("page");
     $page = empty($page) ? 0 : $page;
     $sidx = I("sidx");
     $sidx = empty($sidx) ? "id" : $sidx;
     $limit = I("rows");
     $limit = empty($limit) ? 1000 : $limit;
     $sord = I("sord");
     $sord = empty($sord) ? "desc" : $sord;
     $start = $limit * $page - $limit;
     $start = $start >= 0 ? $start : 0;
     $model = D("Goods");
     $brand_id = get_brand_id();
     $condition = array("brand_id" => $brand_id);
     $category_id = I("category_id");
     if ($category_id != -1 && $category_id !== '') {
         $condition["category_id"] = $category_id;
     }
     $sale_type = I("sale_type");
     if ($sale_type != -1 && $sale_type !== '') {
         $condition["sale_type"] = $sale_type;
     }
     $name = I("name");
     if ($name != -1 && $name !== '') {
         $condition["name"] = array("like", "%{$name}%");
     }
     $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select();
     $count = $model->where($condition)->count();
     $club = I("club");
     $goods = array();
     if ($club != -1 && $club !== '') {
         foreach ($ret as $key => $value) {
             if (!empty($value['clubs'])) {
                 foreach ($value['clubs'] as $clubobj) {
                     if ($clubobj['club_id'] == $club) {
                         $goods[] = $value;
                         break;
                     }
                 }
             }
         }
     } else {
         $goods = $ret;
     }
     $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select();
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $goods, "userdata" => $clubs);
     $this->ajaxReturn($response);
 }