コード例 #1
0
 public function hdfk()
 {
     if (mc_user_id()) {
         if (!$_POST['buyer_name']) {
             $this->error('请填写收货人姓名');
         } elseif (!$_POST['buyer_city']) {
             $this->error('请选择省份和城市');
         } elseif (!$_POST['buyer_address']) {
             $this->error('请填写详细地址');
         } elseif (!$_POST['buyer_phone']) {
             $this->error('请填写联系电话');
         } else {
             $now = strtotime("now");
             $cart = M('action')->field('id,page_id,action_value')->where(array("user_id" => mc_user_id(), "action_key" => 'cart'))->select();
             //dump($cart);die;
             if ($cart) {
                 $item = '';
                 //保存商品名
                 $sumPrice = '';
                 //保存商品总价
                 foreach ($cart as $key => $val) {
                     //echo $val['page_id'].':'.$val['action_value'].'<br />';
                     $itemTitle = M('page')->field('title')->where(array('id' => $val['page_id']))->find();
                     $item .= $itemTitle['title'] . '、';
                     $itemPrice = M('meta')->field('meta_value')->where(array('page_id' => $val['page_id'], 'meta_key' => 'price'))->find();
                     $sumPrice += floatval($itemPrice['meta_value']) * intval($val['action_value']);
                     //dump($itemPrice);
                 }
                 $action['date'] = $now;
                 $action['action_key'] = 'wait_hdfk';
                 M('action')->where("user_id='" . mc_user_id() . "' AND action_key='cart'")->save($action);
                 M('action')->where("user_id='" . mc_user_id() . "' AND action_key='address_pending'")->delete();
                 M('action')->where("user_id='" . mc_user_id() . "' AND action_key='trade_pending'")->delete();
                 $action['page_id'] = mc_user_id();
                 $action['user_id'] = mc_user_id();
                 $action['action_key'] = 'address_wait_hdfk';
                 $action['action_value'] = '<h4>' . I('param.buyer_name') . '</h4><p>' . I('param.buyer_province') . ',' . I('param.buyer_city') . ',' . I('param.buyer_address') . '</p><p>' . I('param.buyer_phone') . '</p>';
                 M('action')->data($action)->add();
                 $action['action_key'] = 'trade_wait_hdfk';
                 $action['action_value'] = $out_trade_no;
                 M('action')->data($action)->add();
                 $id = mc_user_id();
                 mc_delete_meta($id, 'buyer_name', 'user');
                 if (I('param.buyer_name')) {
                     mc_add_meta($id, 'buyer_name', I('param.buyer_name'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_province', 'user');
                 if (I('param.buyer_province')) {
                     mc_add_meta($id, 'buyer_province', I('param.buyer_province'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_city', 'user');
                 if (I('param.buyer_city')) {
                     mc_add_meta($id, 'buyer_city', I('param.buyer_city'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_address', 'user');
                 if (I('param.buyer_address')) {
                     mc_add_meta($id, 'buyer_address', I('param.buyer_address'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_phone', 'user');
                 if (I('param.buyer_phone')) {
                     mc_add_meta($id, 'buyer_phone', I('param.buyer_phone'), 'user');
                 }
                 $mobaddrname = I('param.buyer_name') . "(" . I('param.buyer_phone') . ")";
                 $mobaddr = I('param.buyer_province') . I('param.buyer_city') . I('param.buyer_address');
                 //给下单人员和商家发送短信通知
                 $this->PHPSMS(I('param.buyer_phone'), I('param.buyer_phone'), rtrim($item, '、'), $sumPrice, $mobaddrname, $mobaddr);
                 $this->PHPSMS('15214328120', I('param.buyer_phone'), rtrim($item, '、'), $sumPrice, $mobaddrname, $mobaddr);
                 $this->success('货到付款订单提交成功!', U('User/index/pro?id=' . mc_user_id()));
             } else {
                 $this->error('购物车里没有任何商品!');
             }
         }
     } else {
         $this->success('请先登陆', U('User/login/index'));
     }
 }
コード例 #2
0
 public function remts($id)
 {
     if (mc_is_admin() || mc_is_bianji()) {
         if (is_numeric($id)) {
             mc_delete_meta($id, 'tuisong');
         }
         $this->success('取消推送成功!', mc_get_url($id));
     } else {
         $this->error('请不要放弃治疗');
     }
 }
コード例 #3
0
 public function edit_term($id)
 {
     if (mc_is_admin() && is_numeric($id)) {
         if ($_POST['title']) {
             $page['title'] = mc_magic_in($_POST['title']);
             M('page')->where("id='{$id}'")->save($page);
             $type = mc_get_page_field($id, 'type');
             if ($type == 'term_pro') {
                 if (is_numeric($_POST['parent'])) {
                     if ($_POST['parent'] == $id) {
                         $this->error('父分类不能为自己!');
                     } else {
                         if (mc_get_meta($id, 'parent', true, 'term')) {
                             mc_update_meta($id, 'parent', $_POST['parent'], 'term');
                         } else {
                             mc_add_meta($id, 'parent', $_POST['parent'], 'term');
                         }
                     }
                 } else {
                     mc_delete_meta($id, 'parent', 'term');
                 }
                 $type_name = 'pro';
             } elseif ($type == 'term_baobei') {
                 $type_name = 'baobei';
             }
             $this->success('编辑分类成功!', U($type_name . '/index/term?id=' . $id));
         } else {
             $this->error('请填写分类名称');
         }
     } else {
         $this->error('哥们,你放弃治疗了吗?', U('home/index/index'));
     }
 }
コード例 #4
0
ファイル: alipayapi.php プロジェクト: xiaowei521/vamshop
    if (I('param.buyer_name')) {
        mc_add_meta($id, 'buyer_name', I('param.buyer_name'), 'user');
    }
    mc_delete_meta($id, 'buyer_province', 'user');
    if (I('param.buyer_province')) {
        mc_add_meta($id, 'buyer_province', I('param.buyer_province'), 'user');
    }
    mc_delete_meta($id, 'buyer_city', 'user');
    if (I('param.buyer_city')) {
        mc_add_meta($id, 'buyer_city', I('param.buyer_city'), 'user');
    }
    mc_delete_meta($id, 'buyer_address', 'user');
    if (I('param.buyer_address')) {
        mc_add_meta($id, 'buyer_address', I('param.buyer_address'), 'user');
    }
    mc_delete_meta($id, 'buyer_phone', 'user');
    if (I('param.buyer_phone')) {
        mc_add_meta($id, 'buyer_phone', I('param.buyer_phone'), 'user');
    }
} else {
    $this->error('购物车里没有任何商品!');
}
//付款金额
if (mc_total() < mc_option('m_youfei')) {
    $mc_total = mc_total() + mc_option('youfei');
} else {
    $mc_total = mc_total();
}
if (I('param.coins') > 0 && I('param.coins') <= mc_coins(mc_user_id())) {
    //积分需大于0,且小于等于现有积分
    $coins_topthis = mc_total() * 50;
コード例 #5
0
 public function edit($id)
 {
     if (is_numeric($id)) {
         if (mc_user_id() == $id) {
             if ($_POST['title']) {
                 $title = M('page')->where("title='" . mc_magic_in($_POST['title']) . "' AND type ='user'")->getField('id');
                 if (is_numeric($title) && $title != $id) {
                     $this->error('昵称已存在!');
                 } else {
                     mc_update_page(mc_user_id(), mc_magic_in($_POST['title']), 'title');
                 }
                 if ($_POST['content']) {
                     mc_update_page(mc_user_id(), mc_magic_in($_POST['content']), 'content');
                 }
                 if ($_POST['user_avatar']) {
                     if (mc_get_meta(mc_user_id(), 'user_avatar', true, 'user')) {
                         mc_update_meta(mc_user_id(), 'user_avatar', mc_magic_in($_POST['user_avatar']), 'user');
                     } else {
                         mc_add_meta(mc_user_id(), 'user_avatar', mc_magic_in($_POST['user_avatar']), 'user');
                     }
                 }
                 if ($_POST['fmimg']) {
                     mc_delete_meta($id, 'fmimg', 'basic');
                     mc_add_meta($id, 'fmimg', mc_magic_in($_POST['fmimg']));
                 }
                 mc_delete_meta($id, 'buyer_name', 'user');
                 if ($_POST['buyer_name']) {
                     mc_add_meta($id, 'buyer_name', mc_magic_in($_POST['buyer_name']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_province', 'user');
                 if ($_POST['buyer_province']) {
                     mc_add_meta($id, 'buyer_province', mc_magic_in($_POST['buyer_province']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_city', 'user');
                 if ($_POST['buyer_city']) {
                     mc_add_meta($id, 'buyer_city', mc_magic_in($_POST['buyer_city']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_address', 'user');
                 if ($_POST['buyer_address']) {
                     mc_add_meta($id, 'buyer_address', mc_magic_in($_POST['buyer_address']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_phone', 'user');
                 if ($_POST['buyer_phone']) {
                     mc_add_meta($id, 'buyer_phone', mc_magic_in($_POST['buyer_phone']), 'user');
                 }
                 if ($_POST['user_email']) {
                     mc_update_meta(mc_user_id(), 'user_email', mc_magic_in($_POST['user_email']), 'user');
                 } else {
                     $this->error('邮箱必须填写!');
                 }
                 if (I('param.pass')) {
                     if (I('param.pass2') == I('param.pass')) {
                         mc_update_meta(mc_user_id(), 'user_pass', md5(I('param.pass') . mc_option('site_key')), 'user');
                         $this->success('修改密码成功,请使用新密码登陆', '?m=user&c=login');
                     } else {
                         $this->error('两次密码必须填写一致!');
                     }
                 } else {
                     $this->success('更新资料成功', U('User/index/edit?id=' . $id));
                 }
             } else {
                 $this->theme(mc_option('theme'))->display('User/edit');
             }
         } else {
             $this->error('禁止访问!');
         }
     } else {
         $this->error('参数错误!');
     }
 }
コード例 #6
0
 public function edit($id = false)
 {
     if (!is_numeric($id)) {
         $id = mc_user_id();
     }
     if (is_numeric($id)) {
         if (mc_user_id() == $id) {
             if (mc_remove_html($_POST['title'], 'all')) {
                 $title = M('page')->where("title='" . mc_magic_in(mc_remove_html($_POST['title'], 'all')) . "' AND type ='user'")->getField('id');
                 if (is_numeric($title) && $title != $id) {
                     $this->error('昵称已存在!');
                 } else {
                     mc_update_page(mc_user_id(), mc_magic_in(mc_remove_html($_POST['title'], 'all')), 'title');
                 }
                 if ($_POST['content']) {
                     mc_update_page(mc_user_id(), mc_magic_in(mc_remove_html($_POST['content'], 'all')), 'content');
                 }
                 if ($_POST['user_avatar']) {
                     if (mc_get_meta(mc_user_id(), 'user_avatar', true, 'user')) {
                         mc_update_meta(mc_user_id(), 'user_avatar', mc_magic_in(mc_save_img_base64($_POST['user_avatar'], 1, 120, 120)), 'user');
                     } else {
                         mc_add_meta(mc_user_id(), 'user_avatar', mc_magic_in(mc_save_img_base64($_POST['user_avatar'], 1, 120, 120)), 'user');
                     }
                 }
                 if ($_POST['fmimg']) {
                     mc_delete_meta($id, 'fmimg', 'basic');
                     mc_add_meta($id, 'fmimg', mc_magic_in(mc_save_img_base64($_POST['fmimg'])));
                 }
                 mc_delete_meta($id, 'buyer_name', 'user');
                 if ($_POST['buyer_name']) {
                     mc_add_meta($id, 'buyer_name', mc_magic_in($_POST['buyer_name']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_province', 'user');
                 if ($_POST['buyer_province']) {
                     mc_add_meta($id, 'buyer_province', mc_magic_in($_POST['buyer_province']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_city', 'user');
                 if ($_POST['buyer_city']) {
                     mc_add_meta($id, 'buyer_city', mc_magic_in($_POST['buyer_city']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_address', 'user');
                 if ($_POST['buyer_address']) {
                     mc_add_meta($id, 'buyer_address', mc_magic_in($_POST['buyer_address']), 'user');
                 }
                 mc_delete_meta($id, 'buyer_phone', 'user');
                 if ($_POST['buyer_phone']) {
                     mc_add_meta($id, 'buyer_phone', mc_magic_in($_POST['buyer_phone']), 'user');
                 }
                 $user_email_now = mc_get_meta(mc_user_id(), 'user_email', true, 'user');
                 if ($_POST['user_email'] != $user_email_now) {
                     $user_email = M('meta')->where("meta_key='user_email' AND type ='user'")->getField('meta_value', true);
                     if (in_array(strip_tags($_POST['user_email']), $user_email)) {
                         $this->error('邮箱已存在!');
                     } else {
                         mc_update_meta(mc_user_id(), 'user_email', mc_magic_in($_POST['user_email']), 'user');
                     }
                 } elseif ($_POST['user_email'] == '') {
                     $this->error('邮箱必须填写!');
                 } else {
                     mc_update_meta(mc_user_id(), 'user_email', mc_magic_in($_POST['user_email']), 'user');
                 }
                 if (I('param.pass')) {
                     if (I('param.pass2') == I('param.pass')) {
                         mc_update_meta(mc_user_id(), 'user_pass', md5(I('param.pass') . mc_option('site_key')), 'user');
                         $this->success('修改密码成功,请使用新密码登陆', U('User/login/index'));
                     } else {
                         $this->error('两次密码必须填写一致!');
                     }
                 } else {
                     $this->success('更新资料成功', U('User/index/edit?id=' . $id));
                 }
             } else {
                 $this->theme(mc_option('theme'))->display('User/edit');
             }
         } else {
             $this->error('禁止访问!');
         }
     } else {
         $this->error('参数错误!', U('User/login/index'));
     }
 }
コード例 #7
0
 public function hdfk()
 {
     if (mc_user_id()) {
         if (!$_POST['buyer_name']) {
             $this->error('请填写收货人姓名');
         } elseif (!$_POST['buyer_city']) {
             $this->error('请选择省份和城市');
         } elseif (!$_POST['buyer_address']) {
             $this->error('请填写详细地址');
         } elseif (!$_POST['buyer_phone']) {
             $this->error('请填写联系电话');
         } else {
             $now = strtotime("now");
             $cart = M('action')->where("user_id='" . mc_user_id() . "' AND action_key='cart'")->select();
             if ($cart) {
                 $action['date'] = $now;
                 $action['action_key'] = 'wait_hdfk';
                 M('action')->where("user_id='" . mc_user_id() . "' AND action_key='cart'")->save($action);
                 M('action')->where("user_id='" . mc_user_id() . "' AND action_key='address_pending'")->delete();
                 M('action')->where("user_id='" . mc_user_id() . "' AND action_key='trade_pending'")->delete();
                 $action['page_id'] = mc_user_id();
                 $action['user_id'] = mc_user_id();
                 $action['action_key'] = 'address_wait_hdfk';
                 $action['action_value'] = '<h4>' . I('param.buyer_name') . '</h4><p>' . I('param.buyer_province') . ',' . I('param.buyer_city') . ',' . I('param.buyer_address') . '</p><p>' . I('param.buyer_phone') . '</p>';
                 M('action')->data($action)->add();
                 $action['action_key'] = 'trade_wait_hdfk';
                 $action['action_value'] = $out_trade_no;
                 M('action')->data($action)->add();
                 $id = mc_user_id();
                 mc_delete_meta($id, 'buyer_name', 'user');
                 if (I('param.buyer_name')) {
                     mc_add_meta($id, 'buyer_name', I('param.buyer_name'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_province', 'user');
                 if (I('param.buyer_province')) {
                     mc_add_meta($id, 'buyer_province', I('param.buyer_province'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_city', 'user');
                 if (I('param.buyer_city')) {
                     mc_add_meta($id, 'buyer_city', I('param.buyer_city'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_address', 'user');
                 if (I('param.buyer_address')) {
                     mc_add_meta($id, 'buyer_address', I('param.buyer_address'), 'user');
                 }
                 mc_delete_meta($id, 'buyer_phone', 'user');
                 if (I('param.buyer_phone')) {
                     mc_add_meta($id, 'buyer_phone', I('param.buyer_phone'), 'user');
                 }
                 foreach ($cart as $val) {
                     //库存、销量
                     $kucun = mc_get_meta($val['page_id'], 'kucun') - 1;
                     mc_update_meta($val['page_id'], 'kucun', $kucun);
                     $xiaoliang = mc_get_meta($val['page_id'], 'xiaoliang') + 1;
                     mc_update_meta($val['page_id'], 'xiaoliang', $xiaoliang);
                 }
                 $this->success('货到付款订单提交成功!', U('User/index/pro?id=' . mc_user_id()));
                 $user_ids = M('meta')->where("meta_key='user_level' AND meta_value='10' AND type = 'user'")->getField('page_id', true);
                 foreach ($user_ids as $val) {
                     mc_mail(mc_get_meta($val, 'user_email', true, 'user'), '网站消息', '您的网站有新的订单,请到管理员后台查看。');
                 }
             } else {
                 $this->error('购物车里没有任何商品!');
             }
         }
     } else {
         $this->success('请先登陆', U('User/login/index'));
     }
 }