Пример #1
0
 public function index()
 {
     if (empty($_COOKIE['aid'])) {
         $this->display('login');
     } else {
         $sqlGood = new sql_goodMod();
         $sqlSend = new sql_sendMod();
         $this->assign('user', $_COOKIE['name']);
         // 获取学校信息
         $school_info = $this->model->table($this->config['school'])->field($field)->where($con)->select();
         $this->assign('s_info', $school_info);
         if ($_COOKIE['power'] == 0) {
             $brand_info = $sqlGood->get_brand_manager(0);
             $this->assign('b_info', $brand_info);
             // 展示经销商
             $admin_info = $sqlGood->get_admin_manager();
             $this->assign('a_info', $admin_info);
             $this->display('index-super');
         } else {
             if ($_COOKIE['power'] == 1) {
                 // $a_id = 2;   ################## 这个是管理员 id,必须严格控制
                 $a_id = $this->in_cookie('aid', None, 1, 'True');
                 $good_info = $sqlGood->get_brand($a_id);
                 $this->assign('g_info', $good_info);
                 // 获取配送员信息
                 $sender_info = $sqlSend->get_sender($a_id);
                 $this->assign('sd_info', $sender_info);
                 $this->display('index');
             }
         }
     }
 }
Пример #2
0
 public function save_school_brand()
 {
     $sqlGood = new sql_goodMod();
     $json = $this->in_post('json', None, 2, 'True');
     $json = urldecode($json);
     $json = json_decode($json, True);
     $s_id = $this->in_post('id', None, 1, 'True');
     $oldObj = $json['oldO'];
     $newObj = $json['newO'];
     foreach ($newObj as $value) {
         $price = floatval($value[2]);
         $point = intval($value[3]);
         $f_id = intval($value[0]);
         $c_id = intval($value[1]);
         $good_res = $sqlGood->get_good_manager($f_id);
         if ($good_res) {
             $data['t_id'] = 1;
             $data['f_id'] = $f_id;
             $data['s_id'] = $s_id;
             $data['c_id'] = $c_id;
             $data['a_id'] = $good_res['a_id'];
             $data['g_name'] = $good_res['g_name'];
             $data['pic'] = $good_res['pic'];
             $data['price'] = $price;
             $data['point'] = $point;
             $this->model->table($this->config['goods'])->data($data)->insert();
         }
     }
     foreach ($oldObj as $value) {
         $price = floatval($value[1]);
         $point = intval($value[2]);
         $g_id = intval($value[0]);
         $con['g_id'] = $g_id;
         $up_data['price'] = $price;
         $up_data['point'] = $point;
         $this->model->table($this->config['goods'])->data($up_data)->where($con)->update();
     }
     echo "suss";
 }
Пример #3
0
 /**
  * 提交订水订单
  * 1、获取用户信息 +  循环获取商品信息
  * 2、判断支付方式,1 为线下支付, 2 为积分兑换 (1、判断商品是否允许积分兑换  2、判断积分是否充足)
  * 3、下单 (总订单 + 订单详情)
  * 4、增加积分
  * 5、刷新订水数量 (collec_water  、 rank_water)
  * 6、查询订水排名 (collec_water)
  */
 public function book()
 {
     $sqlGood = new sql_goodMod();
     $this->init();
     $shopCar = $this->in_get('shopCar', None, 2, 'True');
     $p_id = $this->p_id;
     $user_res = $this->apiUser->get_info_user_mysql($p_id);
     // 获取用户信息
     $shopCar = urldecode($shopCar);
     // $order_json = json_decode('{"p_type":0,"order":[{"num":2,"gid":2}]}', True);
     $order_json = json_decode($shopCar, True);
     $pay_type = intval($order_json['p_type']);
     $order = $order_json['order'];
     if ($user_res) {
         $tempArr = array('num' => 0, 'total_fee' => 0, 'points' => 0, 'consume_points' => 0);
         // 用于计算总订单的详细相关信息
         // 用于处理订单数据
         foreach ($order as $key => $value) {
             $gid = intval($value['gid']);
             $g_res = $sqlGood->get_info_good($gid, $user_res['s_id']);
             // 获取商品信息
             $con_flag = True;
             if ($g_res) {
                 $user_res['g_id'] = $g_res['f_id'];
                 // 获取品牌的id
                 $user_res['a_id'] = $g_res['a_id'];
                 // 获取经销商的 id
                 $user_res['g_name'] = $g_res['g_name'];
                 // 获取商品名称
                 $num = intval($value['num']);
                 $tempArr['num'] += $num;
                 $tempArr['total_fee'] += $g_res['price'] * $num;
                 $tempArr['points'] += $g_res['point'] * $num;
                 $con_point = $g_res['consume_point'];
                 if ($con_point < 1) {
                     $con_flag = False;
                 }
                 $tempArr['consume_points'] += $con_point * $num;
             } else {
                 $this->alert('对不起,此商品暂时缺货');
             }
         }
         // 将订单数据存储到数据库中
         if ($pay_type == 0) {
             # 表示使用线下支付
             $this->write_order($user_res, $tempArr, 0);
             $finalPoint = $user_res['point'] + $tempArr['points'];
         } else {
             if ($pay_type == 1) {
                 # 表示积分抵扣
                 if ($con_flag) {
                     if ($user_res['point'] < $tempArr['consume_points']) {
                         $this->alert('对不起,您的积分不足抵扣');
                     } else {
                         $this->write_order($user_res, $tempArr, 1);
                         $finalPoint = $user_res['point'] - $tempArr['consume_points'] + $tempArr['points'];
                     }
                 } else {
                     $this->alert('对不起,此商品暂不支持积分兑换');
                 }
             }
         }
         // 增加积分
         $up_data['point'] = $finalPoint;
         $up_con['p_id'] = $p_id;
         $this->model->table($this->config['info_person'])->data($up_data)->where($up_con)->update();
         // 更新个人这个月订水用量情况 && 设置个人这个月订水数量
         $this_Month = date('Y-m');
         $order_res = $this->apiUser->get_statistic_water_mysql($p_id, $this_Month);
         if ($order_res) {
             $cur_num = $order_res['num'] + $tempArr['num'];
             // 目前总订水量
             $cur_fee = $order_res['fee'] + $tempArr['total_fee'];
             // 目前费用支出
             $new_ratio = $this->apiUser->set_rank_water_mysql($order_res['num'], $cur_num);
             if ($new_ratio) {
                 $this->apiUser->set_statistic_water_mysql($p_id, $this_Month, $cur_num, $cur_fee, $new_ratio['ratio'], 1);
             }
         } else {
             $cur_num = $tempArr['num'];
             // 目前总订水量
             $cur_fee = $tempArr['total_fee'];
             // 目前费用支出
             $new_ratio = $this->apiUser->set_rank_water_mysql(0, $cur_num);
             if ($new_ratio) {
                 $this->apiUser->set_statistic_water_mysql($p_id, $this_Month, $cur_num, $cur_fee, $new_ratio['ratio']);
             }
         }
         $this->set_cookie('point', $tempArr['points']);
         $this->set_cookie('addr', $user_res['addr']);
         $this->set_cookie('type_name', $g_res['g_name']);
         $this->set_cookie('num', $tempArr['num']);
         $this->set_cookie('cur_num', $cur_num);
         $this->set_cookie('cur_fee', $cur_fee);
         $this->set_cookie('rank', $new_ratio['ratio']);
         $this->redirect(__URL__ . '/suss');
         // over
     } else {
         $this->alert('对不起,请您进行注册');
     }
 }