Esempio n. 1
0
function get_group_price($unionid)
{
    $unionid = explode('、', $unionid);
    $total = "";
    foreach ($unionid as $val) {
        $id = $val;
        $total += get_good_price($id);
    }
    return $total;
}
Esempio n. 2
0
 public function getPriceByuid()
 {
     $user = D("member");
     $uid = $user->uid();
     //数量为0,价钱为0
     if ($this->getCnt() == 0) {
         return 0;
     }
     $price = 0.0;
     $data = M("shopcart")->where("uid='{$uid}'")->select();
     foreach ($data as $k => $val) {
         $id = $val['goodid'];
         $price = get_good_price($id);
         $total += $val['num'] * $price;
     }
     return sprintf("%01.2f", $total);
 }
 public function getPriceByuid()
 {
     $user = D("member");
     $uid = $user->uid();
     $map["uid"] = $uid;
     //数量为0,价钱为0
     if ($this->getCnt() == 0) {
         return 0;
     } else {
         $total = 0.0;
         $data = $this->where($map)->select();
         foreach ($data as $k => $val) {
             $id = $val['goodid'];
             $price = get_good_price($id);
             $total += $val['num'] * $price;
         }
     }
     return sprintf("%01.2f", $total);
 }
 public function cancel()
 {
     $this->meta_title = '取消订单';
     /* 左侧菜单 */
     $menu = R('index/menulist');
     $this->assign('categoryq', $menu);
     /* 购物车调用*/
     $cart = R("shopcart/usercart");
     $this->assign('usercart', $cart);
     if (!session('user_auth')) {
         $usercart = $_SESSION['cart'];
         $this->assign('usercart', $usercart);
     }
     /* 底部分类调用*/
     $menulist = R('Service/AllMenu');
     $this->assign('footermenu', $menulist);
     /* 热词调用*/
     $hotsearch = R("Index/getHotsearch");
     $this->assign('hotsearch', $hotsearch);
     if (IS_POST) {
         $id = I('post.id');
         //获取orderid
         $order = M("order");
         $status = $order->where("orderid='{$id}'")->getField("status");
         $num = $order->where("orderid='{$id}'")->getField("ispay");
         $shopid = $order->where("orderid='{$id}'")->getField("id");
         $data = $order->where("id='{$shopid}'")->select();
         foreach ($data as $k => $val) {
             $goodid = $val['goodid'];
             $price = get_good_price($goodid);
             /*取消的商品总额*/
             $cash += $val['num'] * $price;
             /*退货中的商品件数*/
             $num += $val['num'];
             /*退货中的商品种类数*/
             $count += 1;
         }
         //订单已提交或未支付直接取消
         if ($num == -1 && $status == 1 || $num == 1 && $status == -1) {
             //设置订单取消
             //保存数据到取消表中后台调用
             $cancel = D("cancel");
             $cancel->create();
             $cancel->create_time = NOW_TIME;
             $cancel->status = 3;
             $cancel->orderid = $id;
             $cancel->cash = $cash;
             //取消的金额
             $cancel->num = $num;
             //取消的数量
             $cancel->count = $count;
             //取消的种类
             $cancel->info = "自助取消";
             $cancel->add();
             //设置订单为订单已取消
             $data = array('status' => '6', 'backinfo' => '订单已关闭');
             //更新订单列表订单状态为已取消,清空取消订单操作
             if ($order->where("orderid='{$id}'")->setField($data)) {
                 $this->success('申请成功,订单已取消', U("center/index"));
             } else {
                 $this->error('申请失败,请重试');
             }
         } else {
             $cancel = D("cancel");
             $cancel->create();
             $cancel->time = NOW_TIME;
             $cancel->status = 1;
             $cancel->orderid = $id;
             $cancel->cash = $cash;
             //取消的金额
             $cancel->num = $num;
             //取消的数量
             $cancel->count = $count;
             //取消的种类
             $cancel->add();
             $data = array('status' => '4');
             //设置订单状态为已提交,发货等状态不变
             if ($order->where("orderid='{$id}'")->setField($data)) {
                 $this->success('申请成功', U("center/allorder"));
             } else {
                 $this->error('申请失败,请重试');
             }
         }
     } else {
         $id = I('get.id');
         //获取orderid
         $msg = "申请取消订单:";
         $order = M("order");
         $detail = $order->where("orderid='{$id}'")->select();
         $num = $order->where("orderid='{$id}'")->getField("status");
         if ($num == "1") {
             $paynum = $order->where("orderid='{$id}'")->getField("ispay");
             if ($paynum == "1") {
                 $info = "当前订单状态为未完成支付";
             }
             if (!$paynum) {
                 $info = "当前订单已提交等待发货中";
             }
         }
         if ($num == "2") {
             $info = "当前提交的订单已发货,需审核通过后取消";
         }
         $list = M("shoplist");
         foreach ($detail as $n => $val) {
             $detail[$n]['id'] = $list->where('orderid=\'' . $val['id'] . '\'')->select();
         }
         $this->assign('info', $info);
         $this->assign('detaillist', $detail);
         $this->assign('id', $id);
         $this->assign('msg', $msg);
         $this->display();
         $this->meta_title = '取消订单';
     }
 }
        }
    }
} else {
    echo "";
}
?>
</ul>
  
  </div>
  <div class="salesrank">
  <h5><span>最近浏览</span></h5>
 <ul><?php 
if (is_array($recent)) {
    $i = 0;
    $__LIST__ = $recent;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $vo) {
            $mod = $i % 2;
            ++$i;
            ?>
<li><a class="picture" href="<?php 
            echo U('Article/detail?id=' . $vo['page']);
            ?>
"><img src="<?php 
            echo get_cover(get_cover_id($vo["page"]), 'path');
            ?>
"  ></a>
  <a class="title" href="<?php 
            echo U('Article/detail?id=' . $vo['page']);
 public function index()
 {
     if (!is_login()) {
         $this->error("您还没有登陆", U("User/login"));
     }
     $this->meta_title = '取消订单';
     if (IS_POST) {
         $id = I('post.id', '', 'strip_tags');
         //获取orderid
         $id = safe_replace($id);
         //过滤
         $order = M("order");
         $status = $order->where("orderid='{$id}'")->getField("status");
         $num = $order->where("orderid='{$id}'")->getField("ispay");
         $shopid = $order->where("orderid='{$id}'")->getField("id");
         $data = $order->where("id='{$shopid}'")->select();
         foreach ($data as $k => $val) {
             $goodid = $val['goodid'];
             $price = get_good_price($goodid);
             /*取消的商品总额*/
             $cash += $val['num'] * $price;
             /*退货中的商品件数*/
             $num += $val['num'];
             /*退货中的商品种类数*/
             $count += 1;
         }
         //订单已提交或未支付直接取消
         if ($num == -1 && $status == 1 || $num == 1 && $status == -1) {
             //设置订单取消
             //保存数据到取消表中后台调用
             $cancel = D("cancel");
             $cancel->create();
             $cancel->create_time = NOW_TIME;
             $cancel->status = 3;
             $cancel->orderid = $id;
             $cancel->cash = $cash;
             //取消的金额
             $cancel->num = $num;
             //取消的数量
             $cancel->count = $count;
             //取消的种类
             $cancel->info = "自助取消";
             $cancel->add();
             addUserLog('取消订单', $uid);
             //设置订单为订单已取消
             $data = array('status' => '6', 'backinfo' => '订单已关闭');
             //更新订单列表订单状态为已取消,清空取消订单操作
             if ($order->where("orderid='{$id}'")->setField($data)) {
                 $this->success('申请成功,订单已取消', U("center/index"));
             } else {
                 $this->error('申请失败,请重试');
             }
         } else {
             $cancel = D("cancel");
             $cancel->create();
             $cancel->time = NOW_TIME;
             $cancel->status = 1;
             $cancel->orderid = $id;
             $cancel->cash = $cash;
             //取消的金额
             $cancel->num = $num;
             //取消的数量
             $cancel->count = $count;
             //取消的种类
             $cancel->add();
             addUserLog('申请取消订单', $uid);
             $data = array('status' => '4');
             //设置订单状态为已提交,发货等状态不变
             if ($order->where("orderid='{$id}'")->setField($data)) {
                 $this->success('申请成功', U("center/allorder"));
             } else {
                 $this->error('申请失败,请重试');
             }
         }
     } else {
         $id = I('get.id', '', 'strip_tags');
         //获取orderid
         $msg = "申请取消订单:";
         $id = safe_replace($id);
         //过滤
         $order = M("order");
         $detail = $order->where("orderid='{$id}'")->select();
         $num = $order->where("orderid='{$id}'")->getField("status");
         if ($num == "1") {
             $paynum = $order->where("orderid='{$id}'")->getField("ispay");
             if ($paynum == "1") {
                 $info = "当前订单状态为未完成支付";
             }
             if (!$paynum) {
                 $info = "当前订单已提交等待发货中";
             }
         }
         if ($num == "2") {
             $info = "当前提交的订单已发货,需审核通过后取消";
         }
         $list = M("shoplist");
         foreach ($detail as $n => $val) {
             $detail[$n]['id'] = $list->where('orderid=\'' . $val['id'] . '\'')->select();
         }
         $this->assign('info', $info);
         $this->assign('detaillist', $detail);
         $this->assign('id', $id);
         $this->assign('msg', $msg);
         $this->display();
         $this->meta_title = '取消订单';
     }
 }
 public function Addgood($a, $b)
 {
     $Tuanid = $a;
     $good = $b;
     $array = explode(',', $good);
     $User = M("Tuanid");
     if ($User->where("Tuanpid='{$Tuanid}'")->select()) {
         $User->where("Tuanpid='{$Tuanid}'")->delete();
         //商品列表如果存在则删除,重新循环遍历
         for ($i = 0; $i < count($array); $i++) {
             $goodid = $array[$i];
             $data["goodid"] = $goodid;
             $data["price"] = get_good_tuanprice($goodid);
             $data["view"] = get_good_view($goodid);
             $data["salenumber"] = get_sales($goodid);
             $data["tuanpid"] = $Tuanid;
             $data["create_time"] = time();
             // 设置用户的创建时间
             $User->add($data);
         }
     } else {
         //商品列表不存在,遍历添加
         for ($i = 0; $i < count($array); $i++) {
             $goodid = $array[$i];
             $data["goodid"] = $goodid;
             $data["Tuanpid"] = $Tuanid;
             $data["price"] = get_good_price($goodid);
             $data["view"] = get_good_view($goodid);
             $data["salenumber"] = get_sales($goodid);
             $data["create_time"] = time();
             // 设置用户的创建时间
             $User->add($data);
         }
     }
 }
                            </a>
                        </div>
                    </div>
                    <div class="name"><a href="<?php 
            echo U('Article/detail?id=' . $article['id']);
            ?>
" benlai-source="1" benlai-location="13-1" target="_blank" title="<?php 
            echo $article["title"];
            ?>
"><?php 
            echo get_good_shorttitle($article["id"]);
            ?>
</a></div>
                    <div class="price">
                        <font>¥</font><span><?php 
            echo get_good_price($article["id"]);
            ?>
</span>
                        <span style="color: #999999; font-size: 12px; font-weight: 400; margin-left: 3px; text-decoration: line-through"><?php 
            echo get_good_yprice($article["id"]);
            ?>
</span>
                    </div>
  </li><?php 
        }
    }
} else {
    echo "";
}
?>
 
Esempio n. 9
0
function get_discount_Byid($id)
{
    $groupbuying = M("document_limitbuying");
    $map['id'] = $id;
    $info = $groupbuying->where($map)->find();
    $price = get_good_price($id);
    $discount = $price * 10 / $info['market_price'];
    return sprintf("%1\$.1f", $discount);
}
 public function getPricetotal($id)
 {
     $data = M("shoplist")->where("orderid='{$id}'")->select();
     foreach ($data as $k => $val) {
         $goodid = $val['goodid'];
         $price = get_good_price($goodid);
         $total += $val['num'] * $price;
     }
     return sprintf("%01.2f", $total);
 }
 public function month()
 {
     $month = date('Y年m月', NOW_TIME);
     /*格式时间戳为 201410*/
     $this->assign('month', $month);
     //date('w',$time); 取到的是星期几 0-6
     //date('W',$time); 取到的是本年度的第几周 1-53
     // php获取本月起始时间戳和结束时间戳
     $beginThismonth = mktime(0, 0, 0, date('m'), 1, date('Y'));
     $endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
     $this->meta_title = '管理首页';
     $title = "本月数据统计 ";
     $q = date('YmdHis', $beginThismonth);
     /*本月一零点格式时间戳为20141020000000*/
     $b = date('YmdHis', $endThismonth);
     /*本月末格式时间戳为201410270000000*/
     /*本月销量统计*/
     $order = M("order")->where("total!=''")->select();
     foreach ($order as $n => $val) {
         $time = $val['create_time'];
         $a = date('YmdHis', $time);
         /*格式时间戳为 20141020000*/
         if ($b > $a && $a > $q) {
             //本月
             /*商品销售额*/
             $salesmoney += $val['total'];
             /*运费*/
             $trans += $val['shipprice'];
             /*总销售额*/
             $total += $val['pricetotal'];
             $id = $val['id'];
             $list = M("shoplist")->where("orderid='{$id}'")->select();
             foreach ($list as $k => $vo) {
                 /*退货中的商品id*/
                 $goodid = $vo['goodid'];
                 $price = get_good_price($goodid);
                 /*销售的商品件数*/
                 $salenum += $vo['num'];
                 /*销售的商品种类数*/
                 $salecount += 1;
             }
         }
     }
     $this->assign('salecount', $salecount);
     $this->assign('salenum', $salenum);
     $this->assign('total', $total);
     /**
      * 本月退货金额、种类、数量计算
      */
     $data = M("backlist")->where("status='1'")->select();
     foreach ($data as $n => $val) {
         /*格式时间戳为 201410240000*/
         $dtime = $val['create_time'];
         $d = date('YmdHis', $dtime);
         if ($b > $d && $d > $q) {
             //当天
             /*退货中的商品id*/
             $goodid = $val['goodid'];
             $price = get_good_price($goodid);
             /*退货中的商品总额*/
             $back += $val['num'] * $price;
             /*退货中的商品件数*/
             $backnum += $val['num'];
             /*退货中的商品种类数*/
             $backcount += 1;
         }
     }
     $this->assign('back', $back);
     $this->assign('backcount', $backcount);
     $this->assign('backnum', $backnum);
     /**
      * 本月换货金额、种类、数量计算
      */
     $data = M("exchange")->where("status='1'")->select();
     foreach ($data as $k => $vo) {
         $qtime = $vo['create_time'];
         $f = date('YmdHis', $qtime);
         if ($b > $f && $f > $q) {
             /*换货中的商品总额*/
             $goodid = $vo['goodid'];
             $price = get_good_price($goodid);
             $change += $vo['num'] * $price;
             /*换货中的商品件数*/
             $changenum += $vo['num'];
             /*换货中的商品种类数*/
             $changecount += 1;
         }
     }
     $this->assign('change', $change);
     $this->assign('changecount', $changecount);
     $this->assign('changenum', $changenum);
     /**
      * 本月申请取消订单金额、种类、数量计算
      */
     $cdata = M("cancel")->where("status='1'")->select();
     foreach ($cdata as $k => $val) {
         /*格式时间戳为 20141024*/
         $cantime = $val['create_time'];
         $s = date('YmdHis', $cantime);
         if ($b > $s && $s > $q) {
             //当天
             /*取消订单的商品总额*/
             $cancel += $val['cash'];
             /*取消订单的商品件数*/
             $cancelnum += $val['num'];
             /*取消订单的商品种类数*/
             $cancelcount += $val['count'];
         }
     }
     $this->assign('cancel', $cancel);
     $this->assign('cancelcount', $cancelcount);
     $this->assign('cancelnum', $cancelnum);
     /*比率统计*/
     $percent_a = $total / ($total + $back + $change + $cancel);
     $percent_b = $back / ($total + $back + $change + $cancel);
     $percent_c = $change / ($total + $back + $change + $cancel);
     $percent_d = $cancel / ($total + $back + $change + $cancel);
     $this->assign('a', $percent_a);
     $this->assign('b', $percent_b);
     $this->assign('c', $percent_c);
     $this->assign('d', $percent_d);
     /*利润*/
     $profits = $total - $back - $change - $cancel;
     $this->assign('profits', $profits);
     /*保存数据到数据库*/
     $turnover = M("turnover");
     $data["sales"] = $total;
     $data["back"] = $back;
     $data["change"] = $change;
     $data["cancel"] = $cancel;
     $data["profits"] = $profits;
     $user = session('user_auth');
     $data["uid"] = $user["uid"];
     $t = date('Ym', NOW_TIME);
     /*格式时间戳为 201410*/
     $data["info"] = $t;
     $sqtime = $turnover->where("status='3'")->order("id desc")->limit(1)->getField("create_time");
     /*格式时间戳为 20141024*/
     $r = date('Ym', $sqtime);
     /*格式时间戳为 20141024*/
     if ($t == $r) {
         /*当天已统计过数据,保存,创建时间不变,更新时间变化*/
         $data["update_time"] = NOW_TIME;
         $turnover->where("create_time='{$sqtime}' and status='3'")->save($data);
     } else {
         /*未统计过数据,新增*/
         $data["status"] = '3';
         $data["create_time"] = NOW_TIME;
         $data["update_time"] = NOW_TIME;
         $turnover->add($data);
     }
     $this->assign('title', $title);
     $this->display();
 }
                <td><A href="<?php 
echo U('Home:Article/detail?id=' . $vo['goodid']);
?>
" > <img src="<?php 
echo get_cover(get_cover_id($info["goodid"]), 'path');
?>
"  width="40" height="40"/><?php 
echo get_good_name($info["goodid"]);
?>
</A></td>
               <td align="center"> <span class="weight"><?php 
echo get_weight($info["goodid"]);
?>
</span>g</td>
                <td align="center"><?php 
echo get_good_price($info["goodid"]);
?>
</td>
                 <td align="center"><?php 
echo $info["num"];
?>
</td>
                
            </tr>
                         </tbody></table>  <BR/>  
		  <div style="color:red">
		  <p style="text-align:right;color:red;width:100%">小计:<?php 
echo $info["total"];
?>
元 </p> 
		   <p style="text-align:right;color:red;width:100%">申请时间:<?php 
 public function change()
 {
     if (IS_POST) {
         $id = I('post.id');
         //获取id
         $num = I('post.num');
         //获取num
         $change = D("change");
         $change->create();
         $change->create_time = NOW_TIME;
         $change->total = $num * get_good_price(I('post.goodid'));
         $change->status = 1;
         $change->add();
         //更改商品的售后信息
         $data['status'] = -4;
         $shop = M("shoplist");
         if ($shop->where("id='{$id}'")->save($data)) {
             $this->success('申请成功');
         } else {
             $this->error('申请失败,或重复操作');
         }
     } else {
         $id = I('get.id');
         //获取id
         $msg = "Tips,提交换货单";
         $detail = M("shoplist")->find($id);
         //获取购物清单
         $this->assign('info', $detail);
         $this->assign('msg', $msg);
         $this->display();
     }
 }
Esempio n. 14
0
 /**
  * 添加商品  添加商品     未用到
  * param int $id 商品主键
  * int $num 购物数量
  */
 public function addgood($id)
 {
     $tag = $_POST['tag'];
     $num = 1;
     $id = $_POST['id'];
     $price = get_good_price($id);
     if (!isset($_SESSION['cart'])) {
         $_SESSION['cart'] = array();
     }
     $item = array();
     //如果该商品已存在则直接加其数量
     if (isset($_SESSION['cart'][$id])) {
         $_SESSION['cart'][$id]['num'] += $num;
         $item['id'] = $id;
         $item['price'] = $price;
         $item['num'] = $_SESSION['cart'][$id]['num'];
         $_SESSION['cart'][$id] = $item;
         $exsit = "1";
     } else {
         $item['id'] = $id;
         $item['price'] = $price;
         $item['num'] = $num;
         $_SESSION['cart'][$id] = $item;
         $exsit = "0";
     }
     $data['status'] = 1;
     $data['price'] = get_good_price($id);
     $coverid = get_cover_id($id);
     $data['src'] = get_good_img($coverid);
     $data['title'] = get_good_name($id);
     $data['exsit'] = $exsit;
     $data['num'] = $item['num'];
     $data['msg'] = '添加成功';
     $this->ajaxReturn($data);
 }
                <td><A href="<?php 
            echo U('Home/Article/detail?id=' . $vo['goodid']);
            ?>
" > <img src="<?php 
            echo get_cover(get_cover_id($vo["goodid"]), 'path');
            ?>
"  width="40" height="40"/><?php 
            echo get_good_name($vo["goodid"]);
            ?>
</A></td>
               <td align="center"> <span class="weight"><?php 
            echo get_weight($vo["goodid"]);
            ?>
</span>g</td>
                <td align="center"><?php 
            echo get_good_price($vo["goodid"]);
            ?>
</td>
                 <td align="center"><?php 
            echo $vo["num"];
            ?>
</td>
                
            </tr><?php 
        }
    }
} else {
    echo "";
}
?>
                 </tbody></table>  <BR/>  
 public function detail()
 {
     /**
      *接收数据并统计
      * @return none
      */
     $day = I('get.day');
     if ($day) {
         /***按天数统计 */
         $a = date('Ymd', $day);
         /*格式时间戳为 20141024*/
         $this->meta_title = date('Y年m月d日', $day) . '的数据统计';
         $title = date('Y年m月d日', $day) . '的数据统计';
         /*销售统计*/
         $order = M("order")->where("total!=''")->select();
         foreach ($order as $n => $val) {
             $time = $val['ptime'];
             $b = date('Ymd', $time);
             if ($a == $b) {
                 //当月
                 /*商品销售额*/
                 $salesmoney += $val['total'];
                 /*运费*/
                 $trans += $val['shipprice'];
                 /*总销售额*/
                 $total += $val['pricetotal'];
                 $id = $val['id'];
                 $list = M("shoplist")->where("orderid='{$id}'")->select();
                 foreach ($list as $k => $vo) {
                     /*退货中的商品id*/
                     $goodid = $vo['goodid'];
                     $price = get_good_price($goodid);
                     /*销售的商品件数*/
                     $salenum += $vo['num'];
                     /*销售的商品种类数*/
                     $salecount += 1;
                 }
             }
         }
         $this->assign('salecount', $salecount);
         $this->assign('salenum', $salenum);
         $this->assign('trans', $trans);
         $this->assign('salesmoney', $salesmoney);
         $this->assign('total', $total);
         /**
          * 当天退货金额、种类、数量计算
          */
         $data = M("backlist")->where("status='1'")->select();
         foreach ($data as $k => $val) {
             /*格式时间戳为 20141024*/
             $time = $val['create_time'];
             $d = date('Ymd', $time);
             if ($a == $d) {
                 //当天
                 /*退货中的商品id*/
                 $goodid = $val['goodid'];
                 $price = get_good_price($goodid);
                 /*退货中的商品总额*/
                 $back += $val['num'] * $price;
                 /*退货中的商品件数*/
                 $backnum += $val['num'];
                 /*退货中的商品种类数*/
                 $backcount += 1;
             }
         }
         $this->assign('back', $back);
         $this->assign('backcount', $backcount);
         $this->assign('backnum', $backnum);
         /**
          * 当天换货金额、种类、数量计算
          */
         $data = M("change")->where("status='1'")->select();
         foreach ($data as $k => $val) {
             $time = $val['create_time'];
             $f = date('Ymd', $time);
             if ($a == $f) {
                 //当天
                 /*换货中的商品总额*/
                 $goodid = $val['goodid'];
                 $price = get_good_price($goodid);
                 $change += $val['num'] * $price;
                 /*换货中的商品件数*/
                 $changenum += $val['num'];
                 /*换货中的商品种类数*/
                 $changecount += 1;
             }
         }
         $this->assign('change', $change);
         $this->assign('changecount', $changecount);
         $this->assign('changenum', $changenum);
         /**
          * 当天申请取消订单金额、种类、数量计算
          */
         $cdata = M("cancel")->where("status='1'")->select();
         foreach ($cdata as $k => $val) {
             /*格式时间戳为 20141024*/
             $stime = $val['create_time'];
             $s = date('Ymd', $stime);
             if ($a == $s) {
                 //当天
                 /*取消订单的商品总额*/
                 $cancel += $val['cash'];
                 /*取消订单的商品件数*/
                 $cancelnum += $val['num'];
                 /*取消订单的商品种类数*/
                 $cancelcount += $val['count'];
             }
         }
         $this->assign('cancel', $cancel);
         $this->assign('cancelcount', $cancelcount);
         $this->assign('cancelnum', $cancelnum);
         /*比率统计*/
         $percent_a = $total / ($total + $back + $change + $cancel);
         $percent_b = $back / ($total + $back + $change + $cancel);
         $percent_c = $change / ($total + $back + $change + $cancel);
         $percent_d = $cancel / ($total + $back + $change + $cancel);
         $this->assign('a', $percent_a);
         $this->assign('b', $percent_b);
         $this->assign('c', $percent_c);
         $this->assign('d', $percent_d);
         /*利润*/
         $profits = $total - $back - $change - $cancel;
         $this->assign('profits', $profits);
         $this->assign('title', $title);
     }
     //天数统计完毕
     $week = I('get.week');
     if ($week) {
         /***按周数统计 */
         $w = date('W', $week);
         /*格式时间戳为本年度周数*/
         $y = date('Y', $week);
         $this->meta_title = $y . "年度第" . date('W', $week) . '周的数据统计';
         $title = $y . "年度第" . date('W', $week) . '周的数据统计';
         /*销售统计*/
         $order = M("order")->where("total!=''")->select();
         foreach ($order as $n => $val) {
             $time = $val['ptime'];
             $b = date('W', $time);
             if ($w == $b) {
                 //
                 /*商品销售额*/
                 $salesmoney += $val['total'];
                 /*运费*/
                 $trans += $val['shipprice'];
                 /*总销售额*/
                 $total += $val['pricetotal'];
                 $id = $val['id'];
                 $list = M("shoplist")->where("orderid='{$id}'")->select();
                 foreach ($list as $k => $vo) {
                     /*退货中的商品id*/
                     $goodid = $vo['goodid'];
                     $price = get_good_price($goodid);
                     /*销售的商品件数*/
                     $salenum += $vo['num'];
                     /*销售的商品种类数*/
                     $salecount += 1;
                 }
             }
         }
         $this->assign('salecount', $salecount);
         $this->assign('salenum', $salenum);
         $this->assign('trans', $trans);
         $this->assign('salesmoney', $salesmoney);
         $this->assign('total', $total);
         /**
          * 当周退货金额、种类、数量计算
          */
         $data = M("backlist")->where("status='1'")->select();
         foreach ($data as $k => $val) {
             /*格式时间戳为 20141024*/
             $time = $val['create_time'];
             $d = date('W', $time);
             if ($w == $d) {
                 //当天周
                 /*退货中的商品id*/
                 $goodid = $val['goodid'];
                 $price = get_good_price($goodid);
                 /*退货中的商品总额*/
                 $back += $val['num'] * $price;
                 /*退货中的商品件数*/
                 $backnum += $val['num'];
                 /*退货中的商品种类数*/
                 $backcount += 1;
             }
         }
         $this->assign('back', $back);
         $this->assign('backcount', $backcount);
         $this->assign('backnum', $backnum);
         /**
          * 当周换货金额、种类、数量计算
          */
         $data = M("change")->where("status='1'")->select();
         foreach ($data as $k => $val) {
             $time = $val['create_time'];
             $f = date('W', $time);
             if ($w == $f) {
                 //同周
                 /*换货中的商品总额*/
                 $goodid = $val['goodid'];
                 $price = get_good_price($goodid);
                 $change += $val['num'] * $price;
                 /*换货中的商品件数*/
                 $changenum += $val['num'];
                 /*换货中的商品种类数*/
                 $changecount += 1;
             }
         }
         $this->assign('change', $change);
         $this->assign('changecount', $changecount);
         $this->assign('changenum', $changenum);
         /**
          * 本周申请取消订单金额、种类、数量计算
          */
         $cdata = M("cancel")->where("status='1'")->select();
         foreach ($cdata as $k => $val) {
             /*格式时间戳为 20141024*/
             $setime = $val['create_time'];
             $se = date('W', $setime);
             if ($w == $se) {
                 //当天
                 /*取消订单的商品总额*/
                 $cancel += $val['cash'];
                 /*取消订单的商品件数*/
                 $cancelnum += $val['num'];
                 /*取消订单的商品种类数*/
                 $cancelcount += $val['count'];
             }
         }
         $this->assign('cancel', $cancel);
         $this->assign('cancelcount', $cancelcount);
         $this->assign('cancelnum', $cancelnum);
         /*比率统计*/
         $percent_a = $total / ($total + $back + $change + $cancel);
         $percent_b = $back / ($total + $back + $change + $cancel);
         $percent_c = $change / ($total + $back + $change + $cancel);
         $percent_d = $cancel / ($total + $back + $change + $cancel);
         $this->assign('a', $percent_a);
         $this->assign('b', $percent_b);
         $this->assign('c', $percent_c);
         $this->assign('d', $percent_d);
         /*利润*/
         $profits = $total - $back - $change - $cancel;
         $this->assign('profits', $profits);
         $this->assign('title', $title);
     }
     //周数统计完毕
     //月份统计完毕
     $month = I('get.month');
     if ($month) {
         /***按月统计 */
         $m = date('Ym', $month);
         /*格式时间戳为 201410*/
         $this->meta_title = date('Y年m月', $month) . '的数据统计';
         $title = date('Y年m月', $month) . '的数据统计';
         /*销售统计*/
         $order = M("order")->where("total!=''")->select();
         foreach ($order as $n => $val) {
             $time = $val['ptime'];
             $b = date('Ym', $time);
             if ($m == $b) {
                 //
                 /*商品销售额*/
                 $salesmoney += $val['total'];
                 /*运费*/
                 $trans += $val['shipprice'];
                 /*总销售额*/
                 $total += $val['pricetotal'];
                 $id = $val['id'];
                 $list = M("shoplist")->where("orderid='{$id}'")->select();
                 foreach ($list as $k => $vo) {
                     /*退货中的商品id*/
                     $goodid = $vo['goodid'];
                     $price = get_good_price($goodid);
                     /*销售的商品件数*/
                     $salenum += $vo['num'];
                     /*销售的商品种类数*/
                     $salecount += 1;
                 }
             }
         }
         $this->assign('salecount', $salecount);
         $this->assign('salenum', $salenum);
         $this->assign('trans', $trans);
         $this->assign('salesmoney', $salesmoney);
         $this->assign('total', $total);
         /**
          * 当月退货金额、种类、数量计算
          */
         $data = M("backlist")->where("status='1'")->select();
         foreach ($data as $k => $val) {
             /*格式时间戳为 20141024*/
             $time = $val['create_time'];
             $d = date('Ym', $time);
             if ($m == $d) {
                 //当天
                 /*退货中的商品id*/
                 $goodid = $val['goodid'];
                 $price = get_good_price($goodid);
                 /*退货中的商品总额*/
                 $back += $val['num'] * $price;
                 /*退货中的商品件数*/
                 $backnum += $val['num'];
                 /*退货中的商品种类数*/
                 $backcount += 1;
             }
         }
         $this->assign('back', $back);
         $this->assign('backcount', $backcount);
         $this->assign('backnum', $backnum);
         /**
          * 当月换货金额、种类、数量计算
          */
         $data = M("change")->where("status='1'")->select();
         foreach ($data as $k => $val) {
             $time = $val['create_time'];
             $f = date('Ym', $time);
             if ($m == $f) {
                 //同月
                 /*换货中的商品总额*/
                 $goodid = $val['goodid'];
                 $price = get_good_price($goodid);
                 $change += $val['num'] * $price;
                 /*换货中的商品件数*/
                 $changenum += $val['num'];
                 /*换货中的商品种类数*/
                 $changecount += 1;
             }
         }
         $this->assign('change', $change);
         $this->assign('changecount', $changecount);
         $this->assign('changenum', $changenum);
         /**
          * 本周申请取消订单金额、种类、数量计算
          */
         $cdata = M("cancel")->where("status='1'")->select();
         foreach ($cdata as $k => $val) {
             /*格式时间戳为 20141024*/
             $sytime = $val['create_time'];
             $sy = date('Ym', $sytime);
             if ($m == $sy) {
                 //当天
                 /*取消订单的商品总额*/
                 $cancel += $val['cash'];
                 /*取消订单的商品件数*/
                 $cancelnum += $val['num'];
                 /*取消订单的商品种类数*/
                 $cancelcount += $val['count'];
             }
         }
         $this->assign('cancel', $cancel);
         $this->assign('cancelcount', $cancelcount);
         $this->assign('cancelnum', $cancelnum);
         /*比率统计*/
         $percent_a = $total / ($total + $back + $change + $cancel);
         $percent_b = $back / ($total + $back + $change + $cancel);
         $percent_c = $change / ($total + $back + $change + $cancel);
         $percent_d = $cancel / ($total + $back + $change + $cancel);
         $this->assign('a', $percent_a);
         $this->assign('b', $percent_b);
         $this->assign('c', $percent_c);
         $this->assign('d', $percent_d);
         /*利润*/
         $profits = $total - $back - $change - $cancel;
         $this->assign('profits', $profits);
         $this->assign('title', $title);
     }
     //周数统计完毕
     $this->display();
 }
Esempio n. 17
0
 public function addgood($id)
 {
     $tag = htmlspecialchars($_POST['tag']);
     $num = 1;
     $id = htmlspecialchars($_POST['id']);
     $price = get_good_price($id);
     if (!isset($_SESSION['cart'])) {
         $_SESSION['cart'] = array();
     }
     $item = array();
     //如果该商品已存在则直接加其数量
     if (isset($_SESSION['cart'][$id])) {
         $_SESSION['cart'][$id]['num'] += $num;
         $item['id'] = $id;
         $item['price'] = $price;
         $item['num'] = $_SESSION['cart'][$id]['num'];
         $_SESSION['cart'][$id] = $item;
         $exsit = "1";
     } else {
         $item['id'] = $id;
         $item['price'] = $price;
         $item['num'] = $num;
         $_SESSION['cart'][$id] = $item;
         $exsit = "0";
     }
     $data['status'] = 1;
     $data['price'] = get_good_price($id);
     $coverid = get_cover_id($id);
     $data['src'] = get_good_img($coverid);
     $data['title'] = get_good_name($id);
     //登录用户,处理详情页ajaxt提交的数据保存到数据库
     if (is_login()) {
         $table = D("shopcart");
         $data['goodid'] = $id;
         $data['num'] = $num;
         $member = D("member");
         $uid = $member->uid();
         $data['uid'] = $uid;
         $pnum = M("shopcart")->where("goodid='{$id}'and uid='{$uid}'")->getField("num");
         if ($pnum) {
             $exsit = "1";
             $data['num'] = $pnum + $num;
             $table->where("goodid='{$id}'and uid='{$uid}'")->save($data);
         } else {
             $data['num'] = $num;
             $table->add($data);
             $exsit = "0";
         }
         $data['sql'] = 'sql';
         $data['num'] = M("shopcart")->where("goodid='{$id}'and uid='{$uid}'")->getField("num");
         $data['msg'] = '添加成功';
         $data['exsit'] = $exsit;
         $this->ajaxReturn($data);
     } else {
         $data['exsit'] = $exsit;
         $data['num'] = $item['num'];
         $data['msg'] = '添加成功';
         $this->ajaxReturn($data);
     }
 }
Esempio n. 18
0
 public function detailByMonth($month)
 {
     $m = date('Ym', $month);
     /*格式时间戳为 201410*/
     $this->meta_title = date('Y年m月', $month) . '的数据统计';
     $title = date('Y年m月', $month) . '的数据统计';
     /*销售统计*/
     $field = 'id,orderid,tag,pricetotal,create_time,status,ispay,total,shipprice';
     $order = M("order")->where("total!=''")->field($field)->select();
     $salesmoney = $trans = $total = $salenum = $salecount = 0;
     foreach ($order as $n => $val) {
         $time = $val['create_time'];
         $b = date('Ym', $time);
         if ($m == $b) {
             //
             /*商品销售额*/
             $salesmoney += $val['total'];
             /*运费*/
             $trans += $val['shipprice'];
             /*总销售额*/
             $total += $val['pricetotal'];
             $id = $val['id'];
             $field = 'id,goodid,num,orderid,uid,status,create_time,price,total,sort,tag,parameters';
             $list = M("shoplist")->field($field)->where("orderid='{$id}'")->select();
             foreach ($list as $k => $vo) {
                 /*退货中的商品id*/
                 $goodid = $vo['goodid'];
                 $price = $vo['price'];
                 /*销售的商品件数*/
                 $salenum += $vo['num'];
                 /*销售的商品种类数*/
                 $salecount += 1;
             }
         }
     }
     $this->assign('salecount', $salecount);
     $this->assign('salenum', $salenum);
     $this->assign('trans', $trans);
     $this->assign('salesmoney', $salesmoney);
     $this->assign('total', $total);
     /**
      * 当月退货金额、种类、数量计算
      */
     $back = $backnum = $backcount = 0;
     $field = 'id,goodid,num,tool,toolid,status,create_time,info,total,shopid';
     $data = M("backlist")->field($field)->where("status='1'")->select();
     foreach ($data as $k => $val) {
         /*格式时间戳为 20141024*/
         $time = $val['create_time'];
         $d = date('Ym', $time);
         if ($m == $d) {
             //当天
             /*退货中的商品id*/
             $goodid = $val['goodid'];
             $price = get_good_price($goodid);
             /*退货中的商品总额*/
             $back += $val['num'] * $price;
             /*退货中的商品件数*/
             $backnum += $val['num'];
             /*退货中的商品种类数*/
             $backcount += 1;
         }
     }
     $this->assign('back', $back);
     $this->assign('backcount', $backcount);
     $this->assign('backnum', $backnum);
     /**
      * 当月换货金额、种类、数量计算
      */
     $field = 'id,goodid,num,tool,toolid,uid,status,create_time,info,total,shopid';
     $change = $changenum = $changecount = 0;
     $data = M("change")->where("status='1'")->field($field)->select();
     foreach ($data as $k => $val) {
         $time = $val['create_time'];
         $f = date('Ym', $time);
         if ($m == $f) {
             //同月
             /*换货中的商品总额*/
             $goodid = $val['goodid'];
             $price = get_good_price($goodid);
             $change += $val['num'] * $price;
             /*换货中的商品件数*/
             $changenum += $val['num'];
             /*换货中的商品种类数*/
             $changecount += 1;
         }
     }
     $this->assign('change', $change);
     $this->assign('changecount', $changecount);
     $this->assign('changenum', $changenum);
     /**
      * 本周申请取消订单金额、种类、数量计算
      */
     $field = 'id,goodid,num,orderid,create_time,shopid,status,cash,count';
     $cancel = $cancelnum = $cancelcount = 0;
     $cdata = M("cancel")->where("status='1'")->field($field)->select();
     foreach ($cdata as $k => $val) {
         /*格式时间戳为 20141024*/
         $sytime = $val['create_time'];
         $sy = date('Ym', $sytime);
         if ($m == $sy) {
             //当天
             /*取消订单的商品总额*/
             $cancel += $val['cash'];
             /*取消订单的商品件数*/
             $cancelnum += $val['num'];
             /*取消订单的商品种类数*/
             $cancelcount += $val['count'];
         }
     }
     $this->assign('cancel', $cancel);
     $this->assign('cancelcount', $cancelcount);
     $this->assign('cancelnum', $cancelnum);
     /*比率统计*/
     $percent_a = $total / ($total + $back + $change + $cancel);
     $percent_b = $back / ($total + $back + $change + $cancel);
     $percent_c = $change / ($total + $back + $change + $cancel);
     $percent_d = $cancel / ($total + $back + $change + $cancel);
     $this->assign('a', $percent_a);
     $this->assign('b', $percent_b);
     $this->assign('c', $percent_c);
     $this->assign('d', $percent_d);
     /*利润*/
     $profits = $total - $back - $change - $cancel;
     $this->assign('profits', $profits);
     $this->assign('title', $title);
 }