作者 anyv
1 个管道 的构建 通过 耗费 1 秒

首页轮播图 立即购买

... ... @@ -20,6 +20,7 @@ class GoodsdetailsController extends WeChatBaseController{
$goods_id = $this -> request -> param();
$data = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where('a.id',$goods_id['goods_id']) -> find();
$this -> assign('price',$data['price']);
$price = explode('.',$data['price']);
$pricing = explode('.',$data['pricing']);
$data['price0'] = $price[0];
... ... @@ -69,6 +70,91 @@ class GoodsdetailsController extends WeChatBaseController{
}
/**
* 立即支付判断
*/
public function goodsdetails_go_pay(){
$uid = cmf_get_current_user_id();
$goods_id = $_POST['id'];
$data[] = Db::name('goods') -> where('id',$goods_id) -> find();
$data[0]['book_num'] = 1;
foreach ($data as $key => $val){
if($data[0]['type'] == $data[$key]['type']){
}else{
$ret['type'] = 3;
return json_encode($ret);
}
}
if($data[0]['type'] == 1){
$indent['uid'] = $uid;
$indent['state'] = 4;
$indent['order_number'] = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
$indent['money'] = $_POST['myprice'];
$indent['create_time'] = time();
$indent['indent_type'] = 1;
$indent['logistic_name'] = 'YTO';
$book_num = 0;
foreach ($data as $key => $val){
$book_num += $val['book_num'];
}
$indent['book_num'] = $book_num;
$indet_id = Db::name('indent') -> insertGetId($indent);
foreach ($data as $key => $val){
$indent_goods['book_name'] = $val['book_name'];
$indent_goods['pricing'] = $val['pricing'];
$indent_goods['price'] = $val['price'];
$indent_goods['number'] = $val['book_num'];
$indent_goods['thumbnail'] = $val['show_img'];
$indent_goods['indent_id'] = $indet_id;
$indent_goods['commission'] = $val['money'];
$indent_goods['goods_id'] = $val['id'];
Db::name('indent_goods ') -> insert($indent_goods);
}
$ret['type'] = 1;
$ret['indet_id'] = $indet_id;
$res = json_encode($ret);
return $res;
}elseif ($data[0]['type'] == 2){
$indent['uid'] = $uid;
$indent['state'] = 4;
$indent['order_number'] = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
$indent['money'] = $_POST['myprice'];
$indent['indent_type'] = 2;
$indent['create_time'] = time();
$book_num = 0;
foreach ($data as $key => $val){
$book_num += $val['book_num'];
}
$indent['book_num'] = $book_num;
$indent['salesman_uid'] = $data[0]['uid'];
$indet_id = Db::name('indent') -> insertGetId($indent);
foreach ($data as $key => $val){
$indent_goods['book_name'] = $val['book_name'];
$indent_goods['pricing'] = $val['pricing'];
$indent_goods['price'] = $val['price'];
$indent_goods['number'] = $val['book_num'];
$indent_goods['thumbnail'] = $val['show_img'];
$indent_goods['indent_id'] = $indet_id;
$indent_goods['commission'] = $val['money'];
$indent_goods['goods_id'] = $val['id'];
Db::name('indent_goods ') -> insert($indent_goods);
}
$ret['type'] = 2;
$ret['indet_id'] = $indet_id;
$res = json_encode($ret);
return $res;
}
}
... ...
... ... @@ -30,6 +30,9 @@ class IndexController extends WeChatBaseController
$data_goods_hot[$key]['price1'] = $price[1];
}
}
//首页轮播图
$slideshow = Db::name('slide_item') -> select();
$this -> assign('slideshow',$slideshow);
//判断用户是否存在
$uid = cmf_get_current_user_id();
$data_my_user = Db::name('my_user') -> where('uid',$uid) -> find();
... ...
... ... @@ -51,7 +51,7 @@ class PayController extends HomeBaseController
'body' => '百荣科技',
'detail' => '以客户为中心 以奋斗者文本',
'out_trade_no' => $data['order_number'],
'total_fee' => $data['money']*100, // 单位:分
'total_fee' => 1, /*$data['money']*100,*/ // 单位:分
'notify_url' => url('portal/pay/notify','','',true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
'openid' => $openid, // trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识,
];
... ... @@ -264,12 +264,12 @@ class PayController extends HomeBaseController
Db::rollback();
}
cache('a1',"789");
/* cache('a1',"789");
$bird = new BirdController;
$createOrder = $bird -> createOrder($order['id']);
cache('yuyue1',$createOrder);
$takeOrder = $bird -> takeOrder($order['id']);
cache('dingyue1',$takeOrder);
cache('dingyue1',$takeOrder);*/
}
return true; // 返回处理完成
});
... ...
... ... @@ -10,7 +10,7 @@
// [ 入口文件 ]
// 调试模式开关
define("APP_DEBUG",false);
define("APP_DEBUG",true);
// 定义CMF根目录,可更改此目录
define('CMF_ROOT', __DIR__ . '/../');
... ...
... ... @@ -129,9 +129,7 @@
</div>
<div class="de_footerRight">
<div class="de_footerRight1" onclick="add_cart({$data.id})">加入购物车</div>
<a href="order_confirm.html">
<div class="de_footerRight2">立即购买</div>
</a>
<div class="de_footerRight2" onclick="buy_now({$data.id})">立即购买</div>
</div>
</div>
</div>
... ... @@ -139,6 +137,25 @@
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script>
/**
* 点击立即购买
*/
function buy_now(id){
price = {$price};
$.post("{:url('Goodsdetails/goodsdetails_go_pay')}",{id:id,myprice:price},function(data){
obj = JSON.parse(data);
if(obj.type == 3){
alert('业务员商品和平台商品不能同时购买!');
}else if(obj.type == 1){
window.location.href = "{:url('Orderpage/order_page')}?indet_id="+obj.indet_id;
}else if(obj.type == 2){
window.location.href = "{:url('Orderpage/order_salesman_ty')}?indet_id="+obj.indet_id;
}
});
}
/**
*点击收藏
*/
function goods_collection(id){
... ...
... ... @@ -45,12 +45,13 @@
<!-- banner -->
<div class="in_banner swiper-container">
<ul class="swiper-wrapper">
<volist name="slideshow" id="vo">
<li class="swiper-slide">
<img src="__TMPL__/public/assets/images/2.png" alt="">
</li>
<li class="swiper-slide">
<img src="__TMPL__/public/assets/images/2.png" alt="">
<a href="{$vo.url}">
<img src="{:cmf_get_image_url($vo.image)}" alt="">
</a>
</li>
</volist>
</ul>
<div class="swiper-pagination"></div>
</div>
... ...