示例#1
0
function sendsms_pricecut($goods_id)
{
    include_once '../send.php';
    $min_price_arr = get_min_price($goods_id);
    if ($min_price_arr['goods_name'] != '') {
        $min_price = $min_price_arr['min_price'];
        $goods_name = $min_price_arr['goods_name'];
        $goods_url = build_uri('goods', array('gid' => $goods_id), $goods_name);
        $goods_url = $GLOBALS['ecs']->url() . $goods_url;
        $sql = "select pricecut_id, mobile,email from " . $GLOBALS['ecs']->table('pricecut') . " where goods_id='{$goods_id}' and price >= '{$min_price}' and status=0 ";
        $list = $GLOBALS['db']->getAll($sql);
        if ($list) {
            for ($i = 0; $i < count($list); $i++) {
                if ($list[$i]['email'] != '') {
                    $content1 = '您关注的商品 ' . $goods_name . ' 已经降价,您可点击下面链接直接进入商品页面浏览或购买!<br><a href="' . $goods_url . '">' . $goods_url . '</a>';
                    send_mail($_CFG['shop_name'], $list[$i]['email'], '您关注的商品' . $goods_name . '已经降价', $content1, 1);
                }
                //开启降价给客户发短信
                if ($GLOBALS['_CFG']['sms_pricecut'] == 1) {
                    //降价通知短信内容
                    $pricecut_content = sprintf($GLOBALS['_CFG']['sms_pricecut_tpl'], $goods_name, $goods_url, $GLOBALS['_CFG']['sms_sign']);
                    if ($list[$i]['mobile'] != '') {
                        $res = sendSMS($list[$i]['mobile'], $pricecut_content);
                        if ($res == true) {
                            $sql = "UPDATE " . $GLOBALS['ecs']->table('pricecut') . " SET status = 2 WHERE pricecut_id = '" . $list[$i]['pricecut_id'] . "'";
                            $GLOBALS['db']->query($sql);
                        } else {
                            $sql = "UPDATE " . $GLOBALS['ecs']->table('pricecut') . " SET status = 1 WHERE pricecut_id = '" . $list[$i]['pricecut_id'] . "'";
                            $GLOBALS['db']->query($sql);
                        }
                    }
                }
            }
        }
    }
}
示例#2
0
文件: flow.php 项目: firsteam/falcons
if ($_REQUEST['step'] == 'update_group_cart') {
    $result = array('error' => 0, 'message' => '', 'content' => '', 'goods_id' => '');
    $rec_id = intval($_REQUEST['rec_id']);
    $number = intval($_REQUEST['number']);
    $goods_id = intval($_REQUEST['goods_id']);
    $result['suppid'] = intval($_REQUEST['suppid']);
    $result['rec_id'] = $rec_id;
    $result['number'] = $number;
    $goods_number = $GLOBALS['db']->getOne("select goods_number from " . $GLOBALS['ecs']->table('goods') . " where goods_id='{$goods_id}'");
    if ($number > $goods_number) {
        $result['error'] = 1;
        $result['content'] = '对不起,您选择的数量超出库存您最多可购买' . $goods_number . "件";
        $result['number'] = $GLOBALS['db']->getOne("select goods_number from " . $GLOBALS['ecs']->table('cart') . " where rec_id = '{$rec_id}'");
        die($json->encode($result));
    }
    $min_price = get_min_price($goods_id, $number, $rec_id);
    //取得当前用户该商品的最小单价
    //file_put_contents('./567.txt',$min_price);
    $sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '{$number}',goods_price = '{$min_price}' WHERE rec_id = {$rec_id}";
    $GLOBALS['db']->query($sql);
    /* 取得商品列表,计算合计 */
    $cart_goods = get_cart_goods();
    $result['min_price'] = $min_price;
    //折扣活动
    $result['your_discount'] = '';
    $discount = compute_discount($result['suppid']);
    if (is_array($discount)) {
        $favour_name = empty($discount['name']) ? '' : join(',', $discount['name']);
        $result['your_discount'] = sprintf($_LANG['your_discount'], $favour_name, price_format($discount['discount']));
    }
    $subtotal = $GLOBALS['db']->getONE("select goods_price * goods_number AS subtotal from " . $GLOBALS['ecs']->table('cart') . " where rec_id = {$rec_id}");
示例#3
0
function sendsms_pricecut($goods_id)
{
    $min_price_arr = get_min_price($goods_id);
    $min_price = $min_price_arr['min_price'];
    $goods_name = $min_price_arr['goods_name'];
    $goods_url = build_uri('goods', array('gid' => $goods_id), $goods_name);
    $goods_url = $GLOBALS['ecs']->url() . $goods_url;
    $sql = "select pricecut_id, mobile,email from " . $GLOBALS['ecs']->table('pricecut') . " where goods_id='{$goods_id}' and price >= '{$min_price}' and status=0 ";
    $res = $GLOBALS['db']->query($sql);
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        if ($row['email']) {
            $content1 = '您关注的商品 ' . $goods_name . ' 已经降价,您可点击下面链接直接进入商品页面浏览或购买!<br><a href="' . $goods_url . '">' . $goods_url . '</a>';
            send_mail($_CFG['shop_name'], $row['email'], '您关注的商品' . $goods_name . '已经降价', $content1, 1);
        }
        if ($row['mobile']) {
            $client = new nusoap_client('http://106.ihuyi.com/webservice/sms.php?WSDL', 'wsdl');
            $client->soap_defencoding = 'UTF-8';
            $client->decode_utf8 = false;
            $client->xml_encoding = 'UTF-8';
            $parameters = array('account' => 'cf_fight', 'password' => 'fight123', 'content' => '您的验证码是:6754。请不要把验证码泄露给其他人。', 'mobile' => $row['mobile']);
            $sendstatus = $client->call('Submit', $parameters);
            if ($sendstatus['SubmitResult']['code'] == '2') {
                $pricecut_status = 2;
            } else {
                $pricecut_status = 1;
            }
            $GLOBALS['db']->query("update " . $GLOBALS['ecs']->table('pricecut') . " set status='{$pricecut_status}' where pricecut_id='{$row['pricecut_id']}' ");
        }
    }
}
示例#4
0
/**
 * 获取通知列表
 * @access  public
 * @return void
 */
function get_pricecut_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 查询条件 */
        $filter['status'] = $_REQUEST['status'] != '-1' ? intval($_REQUEST['status']) : '-1';
        $filter['mobile'] = !empty($_REQUEST['mobile']) ? trim($_REQUEST['mobile']) : '';
        $where = " where 1 ";
        $where .= $filter['status'] != '-1' ? " AND p.status='{$filter['status']}' " : "";
        $where .= !empty($filter['mobile']) ? " AND p.mobile='{$filter['mobile']}' " : "";
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('pricecut') . " AS p {$where} ";
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 分页大小 */
        $filter = page_and_size($filter);
        $sql = "SELECT p.*, g.goods_name FROM " . $GLOBALS['ecs']->table('pricecut') . " AS p  " . " left join " . $GLOBALS['ecs']->table('goods') . " AS g on p.goods_id=g.goods_id {$where}" . " ORDER BY p.status asc , p.pricecut_id desc";
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $row['notice_status'] = $GLOBALS['notice_status'][$row['status']];
        $row['add_time'] = local_date('Y-m-d H:i:s', $row['add_time']);
        $row['min_price'] = get_min_price($row['goods_id']);
        $row['min_price_format'] = price_format($row['min_price']);
        $row['price_format'] = price_format($row['price']);
        $arr[] = $row;
    }
    $arr = array('item' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}