public function get_flash_sale($goods) { $flash_sale = array(); if (!$goods) { $ret = array("status" => 0, "msg" => "没有该商品!"); return $ret; // Tiny::log(__FILE__ . __LINE__ . "该商品为NULL"); } if (isset($goods['goods_id'])) { $goods_id = $goods['goods_id']; $model = new Model('flash_sale as fs'); $time = date('Y-m-d H:i:s'); // 正在进行的限时抢购 $flash_sale = $model->join("left join goods as go on fs.goods_id=go.id")->fields("*")->where("fs.goods_id = {$goods_id} and start_time < '" . $time . "' and end_time > '" . $time . "'")->find(); $ret = array("status" => 1, "msg" => "没有该商品!", "data" => $flash_sale); return $ret; } else { $ret = array("status" => 0, "msg" => "没有该商品!"); return $ret; } }
protected function _fetcher(Model $fetcher, &$param) { $fetcher->join($this->_type); }
public function flashbuy_num() { $id = Filter::int(Req::args('id')); $num = Filter::int(Req::args('num')); if ($num <= 0) { $num = 1; } $product_id = Filter::int(Req::args('pid')); $model = new Model("flash_sale as fb"); $item = $model->join("left join goods as go on fb.goods_id=go.id left join products as pr on pr.id={$product_id}")->fields("*,pr.id as product_id")->where("fb.id={$id}")->find(); $product = $this->packFlashbuyProducts($item, $num); echo JSON::encode($product); }
/** *编辑会员信息 **/ public function editmemberinfo() { $wxid = $this->_get("wid"); if (isset($wxid) && !IS_POST) { $where = array('tp_userinfo.token' => $this->token, 'tp_userinfo.status' => 1, 'tp_wecha_user.token' => $this->token, 'tp_member_card_create.token' => $this->token, 'tp_member_card_create.status' => 1, 'tp_wecha_user.id' => $wxid); $model = new Model('userinfo'); //'tp_wecha_user as wu on wu.wecha_id = member.wecha_id left join tp_member_card_create as card on card.wecha_id = member.wecha_id '; $res = $model->join('tp_wecha_user on tp_wecha_user.wecha_id = tp_userinfo.wecha_id')->join('tp_member_card_create on tp_member_card_create.wecha_id = tp_userinfo.wecha_id')->where($where)->field(' tp_userinfo.token, tp_userinfo.wecha_id, tp_userinfo.info, tp_userinfo.total_score, tp_userinfo.spend_score, tp_userinfo.sign_score, tp_userinfo.expend_score, tp_userinfo.total_money, tp_userinfo.spend_money, tp_userinfo.memberinfo as extinfo, tp_wecha_user.*, tp_member_card_create.id as Member_card_create_id, tp_member_card_create.number, tp_member_card_create.groupid, tp_member_card_create.getcardtime, tp_wecha_user.userinfo')->find(); $member_card_set = M('member_card_set')->where(array('token' => $this->token))->field('default_show_cols,text_cols,select_cols')->find(); $extInfoData = unserialize($res['extinfo']); $addressInfoData = unserialize($res['address']); $this->assign('addressData', $addressInfoData); $this->assign('extDatas', $extInfoData); if (!empty($member_card_set['default_show_cols'])) { $this->assign('default_show_cols', unserialize($member_card_set['default_show_cols'])); } $text_cols = unserialize($member_card_set['text_cols']); if (!empty($text_cols)) { $this->assign('text_cols', $text_cols); } $select_cols = unserialize($member_card_set['select_cols']); if (!empty($select_cols)) { $this->assign('select_cols', $select_cols); } $class_con = array('token' => $this->token, 'status' => 1); $class_info = M('member_group')->where($class_con)->field('groupid,title')->select(); if (empty($class_info)) { $class_info = C('MEMBER_GROUP'); } $this->assign('class_info', $class_info); $this->assign('memberSet', $memberSet); $this->assign('data', $res); //dump($res); $this->display(); } if (IS_POST) { $wechauserinfo = M('wecha_user')->where(array('token' => $this->token, 'id' => $wxid))->find(); if (!$wechauserinfo) { $this->error("未找到要要修改的会员!"); exit; } $wecha_id = $wechauserinfo['wecha_id']; $defaultinfochanged = $_POST['defaultinfochanged'] || $_POST['oldbirthday'] != $_POST['birthday']; $classchanged = $_POST['oldgroupid'] != $_POST['groupid']; $extinfochanged = $_POST['extinfochanged']; $upUserinfoSuccess = false; $upMemberClassSuccess = false; $upExtInfoSuccess = false; $extinfo = array('select_cols' => $_POST['select_cols'], 'text_cols' => $_POST['text_cols']); $address = array('addr_detail' => $_POST['addr_detail'], 'addr_prov' => $_POST['addr_prov'], 'addr_city' => $_POST['addr_city'], 'addr_area' => $_POST['addr_area']); //判断userinfo是否有改动,如果没有改动,则save方法返回0, if ($defaultinfochanged) { $userupdata = array_diff($_POST, $extinfo, $address); $userupdata['token'] = $this->token; $userupdata['wecha_id'] = $wecha_id; $userupdata['address'] = serialize($address); //exit(); $m = M('wecha_user'); $upUserinfoSuccess = $m->where(array('id' => $_POST['id'], 'token' => $this->token))->save($userupdata); } if ($extinfochanged) { $extinfodata['memberinfo'] = serialize($extinfo); $upExtInfoSuccess = M('userinfo')->where(array('token' => $this->token, 'wecha_id' => $wecha_id, 'status' => 1))->save($extinfodata); } //判断member_card_create的groupid是否改动,若改动则提交 if ($classchanged) { $updata = array('id' => $_POST['Member_card_create_id'], 'groupid' => $_POST['groupid']); $upMemberClassSuccess = M('Member_card_create')->where(array('id' => $updata['id'], 'token' => $this->token, 'status' => 1))->save($updata); } $succ = ($infochanged ? $upUserinfoSuccess : true) && ($classchanged ? $upMemberClassSuccess : true) && ($extinfochanged ? $upExtInfoSuccess : true); if (!$succ) { $this->error('服务器繁忙,请稍候再试'); } else { $this->success('操作成功'); } } }
public function customer_edit() { $id = Req::args("id"); $customer = Req::args(); if ($id) { $model = new Model("customer as c"); $customer = $model->join("user as u on c.user_id = u.id")->where("c.user_id=" . $id)->find(); } $this->redirect('customer_edit', false, $customer); }
public function order_status() { $parse_status = array('3' => '审核订单', '4' => '完成订单成功', '6' => '作废订单'); $id = Filter::int(Req::args("id")); $status = Req::args("status"); $admin_remark = Req::args("remark"); $model = new Model("order"); $order = $model->where("id={$id}")->find(); $flag = false; $info = array(); if ($order) { if ($status) { if ($order['status'] == 1 || $order['status'] == 2) { if ($status == 3 || $status == 6) { $flag = true; } /* S 二次开发 */ if ($status == 3) { //发送邮件 $user_id = $order['user_id']; $user_model = new Model('user'); $user = $user_model->where('id=' . $user_id)->find(); $order_url = Url::fullUrlFormat("/ucenter/order_detail/id/{$order['id']}"); $email_message_model = new Model('email_message'); $email_message = $email_message_model->where('`trigger`=2 and status=1')->find(); if ($email_message) { $body = str_replace(array('{$order_no}', '{$user_name}', '{$current_time}', '{$order_url}'), array($order['order_no'], $user['name'], date('Y-m-d H:i:s'), $order_url), $email_message['content']); $mail = new Mail(); $mail->send_email($user['email'], $email_message['title'], $body); } } /* E 二次开发*/ } if ($order['status'] == 3) { if ($status == 4 || $status == 6) { $flag = true; } if ($status == 4) { //货到付款的订单处理 $payment_plugin = Common::getPaymentInfo($order['payment']); if ($payment_plugin != null && $payment_plugin['class_name'] == 'received') { Order::updateStatus($order['order_no']); } //订单完成 $model_tem = new Model('order'); $model_tem->where("id={$id}")->data(array('delivery_status' => 2, 'status' => 4, 'completion_time' => date('Y-m-d H:i:s')))->update(); //允许评价 $model_tem = new Model('order as od'); $products = $model_tem->join('left join order_goods as og on od.id=og.order_id')->where('od.id=' . $id)->findAll(); foreach ($products as $product) { $data = array('goods_id' => $product['goods_id'], 'user_id' => $order['user_id'], 'order_no' => $product['order_no'], 'buy_time' => $product['create_time']); $model_tem->table('review')->data($data)->insert(); } } } if ($order['status'] == 4 && $status == 6) { $flag = true; } if ($flag) { $model->where("id={$id}")->data(array('status' => $status, 'admin_remark' => $admin_remark))->update(); $info = array('status' => 'success', 'msg' => $parse_status[$status]); } else { $info = array('status' => 'fail', 'msg' => $parse_status[$status]); } } else { $op = Req::args("op"); if ($op == 'note') { $model->where("id={$id}")->data(array('admin_remark' => $admin_remark))->update(); $info = array('status' => 'success', 'msg' => '备注'); } else { if ($op == 'del') { $model->where("id={$id}")->delete(); $info = array('status' => 'success', 'msg' => '删除'); } } } } else { $info = array('status' => 'fail', 'msg' => '不存在此订单'); } echo JSON::encode($info); }
public function payment_list() { $model = new Model('payment as pa'); $list = $model->join("left join pay_plugin as pi on pa.plugin_id = pi.id")->fields("pa.id,pa.plugin_id,pa.pay_name,pa.description as pay_description,pa.status,pi.description,pi.logo,pi.class_name")->order('pa.sort desc')->findAll(); $this->assign("payment_list", $list); $this->redirect('payment_list'); }
public function hot() { $model = new Model("order_goods as og"); $cal = $this->calendar(); $stime = $cal['start']; $etime = $cal['end']; $s_time = $cal['str']; $days = $cal['days']; $monthData = array(); $xdata = array(); if ($days < 3) { $rows = $model->join("left join order as od on od.id = og.order_id")->fields("count(og.id) as num,og.goods_id,TIME_FORMAT(od.create_time, '%H:00') as day ,od.order_amount as amount")->where("od.create_time between '{$stime}' and '{$etime}' and od.pay_status=1")->order('num desc')->group("og.goods_id")->limit(3)->findAll(); for ($i = 0; $i < 24; $i++) { $xdata[($i < 10 ? '0' . $i : $i) . ':00'] = 0.0; } foreach ($rows as $row) { $monthData[$row['goods_id']] = $xdata; } } else { $rows = $model->join("left join order as od on od.id = og.order_id")->fields("count(og.id) as num,og.goods_id,date_format(od.create_time,'%m-%d') as day ,od.order_amount as amount")->where("od.create_time between '{$stime}' and '{$etime}' and od.pay_status=1")->order('num desc')->group("og.goods_id")->limit(3)->findAll(); $month_day = null; for ($i = 0; $i < $days; $i++) { $month_day = date("m-d", strtotime($stime . '+' . $i . 'day')); $xdata[$month_day] = 0.0; } foreach ($rows as $row) { $monthData[$row['goods_id']] = $xdata; } } if ($rows) { foreach ($rows as $row) { $monthData[$row['goods_id']][$row['day']] = $row['amount']; } foreach ($rows as $row) { $data[$row['goods_id']] = implode(",", $monthData[$row['goods_id']]); } $goods_id = implode(",", array_keys($data)); $goods = $model->table("goods")->where("id in ({$goods_id})")->findAll(); $parse_goods = array(); foreach ($goods as $v) { $parse_goods[$v['id']] = $v['name']; } $this->assign("parse_goods", $parse_goods); } $month = implode("','", array_keys($xdata)); $this->assign("nodata", implode(",", array_values($xdata))); $this->assign("s_time", $s_time); $this->assign("month", "'{$month}'"); $this->assign("data", isset($data) ? $data : array()); $this->redirect(); }
public function __construct($payment_id) { $this->payment_id = $payment_id; $model = new Model("payment as pa"); $this->payment = $model->join("left join pay_plugin as pi on pa.plugin_id = pi.id")->where("pa.id = " . $payment_id)->find(); }
static function getPaymentInfo($id) { $model = new Model('payment as pa'); $payment = $model->join('left join pay_plugin as pp on pa.plugin_id = pp.id')->where("pa.id = " . $id)->find(); return $payment; }
public function flash() { $this->assign('seo_title', '精品热卖'); $this->assign('seo_keywords', '抢购,优惠促销精选,限时抢购,更多优惠.'); $model = new Model('flash_sale as fs'); // EC 变更 2015-06-08 16:05 今日特卖没有的场合,bug对应 START // $listTop = array(); // $listPart = array(); $listTop = null; $listPart = null; // EC 变更 2015-06-08 16:05 今日特卖没有的场合,bug对应 END $current_time = date('Y-m-d H:i:s'); $isEnd_0 = 'fs.is_end = 0'; $isEnd_1 = 'fs.is_end = 1'; $beforeNow = 'fs.start_time <= "' . $current_time . '"'; $afterNow = 'fs.start_time > "' . $current_time . '"'; $start_time_DESC = 'fs.start_time DESC'; $start_time_ASC = 'fs.start_time ASC'; $left_join = 'left join goods as gd on gd.id = fs.goods_id'; $and = ' and '; //判断是否有进行中的活动 $hasFlash = $model->where($isEnd_0 . $and . $beforeNow)->find(); //判断是否有即将开始的活动 $willFlash = $model->where($isEnd_1 . $and . $afterNow)->find(); //进行中和马上开始 混在 if ($hasFlash && $willFlash) { // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 START // $listTop = $model->join($left_join)->where($isEnd_0.$and.$beforeNow)->order($start_time_DESC)->find(); $listTop = $model->fields("fs.id, fs.title, fs.max_num, fs.quota_num, fs.price, fs.goods_id, fs.description, fs.start_time, fs.end_time, fs.goods_num, fs.order_num, fs.is_end, fs.img as fs_img, gd.*")->join($left_join)->where($isEnd_0 . $and . $beforeNow)->order($start_time_DESC)->find(); // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 END $list1 = $model->join($left_join)->where($isEnd_0 . $and . $beforeNow . $and . 'fs.goods_id <>' . $listTop['goods_id'])->order($start_time_DESC)->findAll(); $list2 = $model->join($left_join)->where($isEnd_1 . $and . $afterNow)->order($start_time_ASC)->findAll(); $listPart = array_merge($list1, $list2); } //只有进行中 if ($hasFlash && !$willFlash) { // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 START // $listTop = $model->join($left_join)->where($isEnd_0.$and.$beforeNow)->order($start_time_DESC)->find(); $listTop = $model->fields("fs.id, fs.title, fs.max_num, fs.quota_num, fs.price, fs.goods_id, fs.description, fs.start_time, fs.end_time, fs.goods_num, fs.order_num, fs.is_end, fs.img as fs_img, gd.*")->join($left_join)->where($isEnd_0 . $and . $beforeNow)->order($start_time_DESC)->find(); // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 END $list1 = $model->join($left_join)->where($isEnd_0 . $and . $beforeNow . $and . 'fs.goods_id <>' . $listTop['goods_id'])->order($start_time_DESC)->findAll(); $listPart = array_merge($list1); } //只有即将开始 if (!$hasFlash && $willFlash) { // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 START // $listTop = $model->join($left_join)->where($isEnd_1.$and.$afterNow)->order($start_time_ASC)->find(); $listTop = $model->fields("fs.id, fs.title, fs.max_num, fs.quota_num, fs.price, fs.goods_id, fs.description, fs.start_time, fs.end_time, fs.goods_num, fs.order_num, fs.is_end, fs.img as fs_img, gd.*")->join($left_join)->where($isEnd_1 . $and . $afterNow)->order($start_time_ASC)->find(); // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 END $list1 = $model->join($left_join)->where($isEnd_1 . $and . $afterNow . $and . 'fs.goods_id <>' . $listTop['goods_id'])->order($start_time_ASC)->findAll(); $listPart = array_merge($list1); } // $instFlashSale = new FlashSale(); // $goodSel = $instFlashSale->getFlashSaleWithProducts(); // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 START if (!isset($listTop["fs_img"]) || $listTop["fs_img"] == "") { $listTop["is_has_fs_img"] = false; } else { $listTop["is_has_fs_img"] = true; } // EC 变更 2015-06-22 12:05 今日特卖宣传图片不表示的场合,bug对应 END $this->assign("listPart", $listPart); $this->assign("listTop", $listTop); //手机端专用 // EC 变更 2015-06-08 16:05 今日特卖没有的场合,bug对应 START $listAll = null; if ($listTop) { $listTmp = array(); array_push($listTmp, $listTop); $listAll = $listTmp; if ($listPart) { $listAll = array_merge($listTmp, $listPart); $this->assign("listAll", $listAll); } } // EC 变更 2015-06-08 16:05 今日特卖没有的场合,bug对应 END $this->assign("listAll", $listAll); $this->redirect(); }