当前位置:

人人商城异步操作菜单示例

本文最后更新于2019-09-30,已超过 1年没有更新,如果文章内容、图片或者下载资源失效,请留言反馈,我会及时处理,谢谢!

温馨提示:本文共2963个字,读完预计8分钟。

 菜单:

<a href='javascript:;' data-toggle='ajaxEdit' data-href="{php echo webUrl('goods/change',array('type'=>'displayorder','id'=>$item['id']))}" >{$item['displayorder']}</a>

服务端方法
public function change()
    {
        global $_W;
        global $_GPC;
        $id = intval($_GPC[‘id’]);

        if (empty($id)) {
            show_json(0, array('message' => '参数错误'));
        }
        else {
            pdo_update('ewei_shop_goods', array('newgoods' => 0), array('id' => $id));
        }

        $type = trim($_GPC[‘type’]);
        $value = trim($_GPC[‘value’]);

        if (!in_array($type, array('title', 'marketprice', 'total', 'goodssn', 'productsn', 'displayorder', 'dowpayment'))) {
            show_json(0, array('message' => '参数错误'));
        }

        $goods = pdo_fetch('select id,hasoption,marketprice,dowpayment,`type`,isdiscount,isdiscount_time from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1', array(':uniacid' => $_W[‘uniacid’], ':id' => $id));

        if (empty($goods)) {
            show_json(0, array('message' => '参数错误'));
        }

        if ($type == 'dowpayment') {
            if ($goods[‘marketprice’] < $value) {
                show_json(0, array('message' => '定金不能大于总价'));
            }
        }
        else {
            if ($type == 'marketprice') {
                if ($value < $goods[‘dowpayment’]) {
                    show_json(0, array('message' => '总价不能小于定金'));
                }
            }
        }

        if ($type == 'total' && $goods[‘type’] == 3) {
            show_json(0, array('message' => '虚拟卡密产品不可直接修改库存'));
        }

        $result = pdo_update('ewei_shop_goods', array($type => $value), array('id' => $id));
        if ($type == 'total' && $result) {
            plog('goods.list', '编辑商品 ID: ' . $id . '<br>库存量为' . $value);
        }

        if ($goods[‘hasoption’] == 0 && !in_array($type, array('displayorder', 'total'))) {
            if ($goods[‘isdiscount’] == 0 || $goods[‘isdiscount_time’] < time()) {
                $sql = 'update ' . tablename('ewei_shop_goods') . (' set minprice = marketprice,maxprice = marketprice where id = ' . $goods[‘id’] . ' and hasoption=0;');
                pdo_query($sql);
            }
            else {
                $sqlgoods = 'SELECT id,title,thumb,marketprice,productprice,minprice,maxprice,isdiscount,isdiscount_time,isdiscount_discounts,sales,total,description,merchsale FROM ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1';
                $goodsinfo = pdo_fetch($sqlgoods, array(':id' => $id, ':uniacid' => $_W[‘uniacid’]));
                $goodsinfo = m('goods')->getOneMinPrice($goodsinfo);
                pdo_update('ewei_shop_goods', array('minprice' => $goodsinfo[‘minprice’], ‘maxprice’ => $goodsinfo[‘maxprice’]), array(‘id’ => $id, ‘uniacid’ => $_W[‘uniacid’]));
            }
        }

        show_json(1);
    }

 

本文链接:,转发请注明来源!
评论已关闭。