123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917 |
- <?php
- namespace Home\Model;
- /**
- * 拼团模型模型
- * @author fish
- *
- */
- class CarModel {
- private $data = array();
-
-
- public function get_wecartall_goods($goods_id, $sku_str, $community_id,$token,$car_prefix='cart.',$soli_id ='')
- {
-
- if( $community_id <=0 )
- {
- return 0;
- }
-
- $key = (int)$goods_id . ':'.$community_id.':';
-
- if( !empty($soli_id) )
- {
- $key .= $soli_id.':';
- }
-
- $key = $car_prefix . $key;
-
-
- $s_arr = M('lionfish_comshop_car')->field('format_data')->where( " token='{$token}' and carkey like '%{$key}%' " )->select();
-
- $quantity = 0;
-
- foreach($s_arr as $val)
- {
- $tmp_format_data = unserialize($val['format_data']);
-
- $quantity += $tmp_format_data['quantity'];
- }
-
- return $quantity;
- }
-
- public function get_wecart_goods_solicount($goods_id, $community_id,$token,$soli_id = '')
- {
-
- $key = (int)$goods_id . ':'.$community_id.':'.$soli_id.':' ;
-
- $key = 'soitairecart.'.$key;
-
- $car_sql = "select format_data from ".C('DB_PREFIX')."lionfish_comshop_car
- where token ='{$token}' and carkey like '{$key}%' ";
- $s_arr = M()->query($car_sql);
-
- if( !empty($s_arr) )
- {
- $s_count = 0;
-
- foreach( $s_arr as $val )
- {
- $tmp_format_data = unserialize($val['format_data']);
-
- $s_count += $tmp_format_data['quantity'];
- }
- return $s_count;
- }else{
- return 0;
- }
-
- }
-
-
-
-
- public function get_wecart_goods($goods_id, $sku_str, $community_id,$token,$car_prefix='cart.',$soli_id = '')
- {
-
- if( $community_id <=0 )
- {
- return 0;
- }
-
-
- $key = (int)$goods_id . ':'.$community_id.':';
-
- if( !empty($soli_id) )
- {
- $key .= $soli_id.':';
- }
-
- if ($sku_str) {
- $key.= base64_encode($sku_str) . ':';
- } else {
- $key.= ':';//xx
- }
- $key = $car_prefix . $key;
-
-
-
-
- //C('DB_PREFIX')
-
- $s_arr = M('lionfish_comshop_car')->field('format_data')->where( array('carkey' => $key,'token' => $token) )->find();
-
- $tmp_format_data = unserialize($s_arr['format_data']);
-
- return $tmp_format_data['quantity'];
- }
-
- //得到商品数量
- public function get_goods_quantity($goods_id) {
-
- $quantity = D('Seller/Redisorder')->get_goods_total_quantity($goods_id);
- if($quantity <= 0)
- {
- $info = M('lionfish_comshop_goods')->field('total as quantity')->where(array('id' =>$goods_id))->find();
- $quantity = $info['quantity'];
- }
- return $quantity;
- }
-
- public function addwecar($token, $goods_id, $format_data = array() , $option, $community_id,$car_prefix='cart.',$soli_id='') {
-
- $key = (int)$goods_id . ':'.$community_id.':';
-
- if( !empty($soli_id) )
- {
- $key .= $soli_id.':';
- }
-
- $qty = $format_data['quantity'];
- if ($option) {
- $key.= base64_encode($option) . ':';
- } else {
- $key.= ':';
- }
-
-
- if( $format_data['is_just_addcar'] == 0 )
- {
-
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like '".$car_prefix."%' ";
- $all_cart = M()->query($cart_sql);
-
-
-
-
- if(!empty($all_cart))
- {
- foreach($all_cart as $val)
- {
- $tmp_format_data = unserialize($val['format_data']);
- $tmp_format_data['singledel'] = 0;
-
- $tmp_format_data_new = array('format_data' => serialize($tmp_format_data) );
-
- M('lionfish_comshop_car')->where( array('id' => $val['id']) )->save( $tmp_format_data_new );
- }
- }
- }
-
-
-
- $carkey = $car_prefix.$key;
-
- $s_arr = M('lionfish_comshop_car')->field('format_data')->where( array('carkey' => $carkey,'token' => $token) )->find();
-
-
- if ((int)$qty && ((int)$qty > 0)) {
- $key = $car_prefix . $key;
- $s = array();
- if (!empty($s_arr)) {
- $s = unserialize($s_arr['format_data']);
- }
- if (!empty($s)) {
- if( $format_data['is_just_addcar'] == 1 )
- {
- $format_data['quantity']+= $s['quantity'];
- }
- }
- }
- if (!empty($s_arr)) {
-
- $car_data = array();
- $car_data['format_data'] = serialize($format_data);
- $car_data['modifytime'] = time();
-
-
- M('lionfish_comshop_car')->where( array('token' => $token,'carkey' => $key) )->save( $car_data );
-
- } else {
-
- $car_data = array();
- $car_data['token'] = $token;
- $car_data['community_id'] = $community_id;
- $car_data['carkey'] = $key;
- $car_data['modifytime'] = time();
- $car_data['format_data'] = serialize($format_data);
-
- M('lionfish_comshop_car')->add( $car_data );
-
-
- }
- $this->data = array();
- }
-
- public function add_activitycar($token, $goods_id, $format_data = array() , $option) {
- global $_W;
- global $_GPC;
-
- $this->removeActivityAllcar($token);
- $key = (int)$goods_id . ':';
- $qty = $format_data['quantity'];
- if ($option) {
- $key.= base64_encode($option) . ':';
- } else {
- $key.= ':';
- }
- $key.= "buy_type:" ;
- if ((int)$qty && ((int)$qty > 0)) {
- $key = 'cart_activity.' . $key;
-
- $carkey = 'cart.'.$key;
-
- $s_arr = M('lionfish_comshop_car')->where( array('token' => $token, 'carkey' => $carkey) )->find();
-
-
- $s = array();
- if (!empty($s_arr)) {
- $s = unserialize($s_arr['format_data']);
- }
- if (!empty($s)) {
- $format_data['quantity']+= $s['quantity'];
- }
- if (!empty($s_arr)) {
-
- $car_data = array();
- $car_data['format_data'] = serialize($format_data);
-
- M('lionfish_comshop_car')->where( array('token' => $token,'carkey' => $key) )->save( $car_data );
-
- } else {
- $car_data = array();
- $car_data['token'] = $token;
- $car_data['carkey'] = $key;
- $car_data['format_data'] = serialize($format_data);
-
- M('lionfish_comshop_car')->add($car_data);
- }
- }
- $this->data = array();
- }
- /**
- * @author yj
- * @desc 获取不同类型的购物车数据
- * @param string $buy_type
- * @param $token
- * @param $community_id
- * @param string $soli_id
- * @return array|mixed
- */
- public function getCarDataByTypeAndHeadIdAndToken( $buy_type = 'dan', $token, $community_id,$soli_id='' )
- {
- $cart = [];
- //单独购买类型
- if ($buy_type == 'dan') {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id='{$community_id}' and carkey like 'cart.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }
- else if( $buy_type == 'pindan' )
- {//拼团单独购买
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id={$community_id} and carkey like 'pindancart.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }else if( $buy_type == 'pintuan' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id={$community_id} and carkey like 'pintuancart.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }
- else if( $buy_type == 'presale' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id={$community_id} and carkey like 'presalecart.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }
- else if( $buy_type == 'virtualcard' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id={$community_id} and carkey like 'virtualcardcart.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }
- else if( $buy_type == 'soitaire' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id={$community_id} and carkey like 'soitairecart.%' order by modifytime desc ";
- $cart_arr = M()->query($cart_sql);
- $cart = array();
- if( !empty($cart_arr) )
- {
- foreach( $cart_arr as $key => $val )
- {
- $key_arr = explode(':', $val['carkey']);
- if( $key_arr[2] == $soli_id )
- {
- $cart[$key] = $val;
- }
- }
- }
- }
- else if( $buy_type == 'integral' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id={$community_id} and carkey like 'integralcart.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }
- else {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id='{$community_id}' and carkey like 'cart_activity.%' order by modifytime desc ";
- $cart = M()->query($cart_sql);
- }
- return $cart;
- }
- /**
- * @author yj
- * @desc 获取所有购物车中的商品
- * @param string $buy_type
- * @param $token
- * @param int $is_pay_need
- * @param $community_id
- * @param string $soli_id
- * @return array
- */
- public function get_all_goodswecar($buy_type = 'dan', $token,$is_pay_need = 1, $community_id,$soli_id='') {
-
-
- if (!($this->data)) {
- //获取购物车中数据
- $cart = $this->getCarDataByTypeAndHeadIdAndToken( $buy_type , $token, $community_id,$soli_id );
- $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
- $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
-
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
-
- //$goods_model = D('Home/Goods');
-
- foreach ($cart as $key => $val_uns) {
-
- $val = unserialize( $val_uns['format_data'] );
-
- if($buy_type =='dan' && $is_pay_need == 1)
- {
- if(isset($val['singledel']) && $val['singledel'] == 0)
- {
- continue;
- }
- }else if($buy_type == 'dan' && $is_pay_need == 0)
- {
- //判断是否支持自提,如果支持自提,那么就不要剔除购物车列表
- //$val['goods_id'] pick_just pick_just
-
- $goods_common_info = D('Seller/Front')->get_goods_common_field($val['goods_id'] , 'pick_just');
-
- $pick_just = $goods_common_info['pick_just'];
-
- if(!empty($pick_just) && isset($pick_just['pick_just']) && $pick_just['pick_just'] > 0)
- {
- //continue;
- }else {
-
-
- }
- }
-
-
-
- //$pin_type = $val['pin_type'];
- $quantity = $val['quantity'];
- //$quantity
- $goods = explode(':', $key);
- $goods_id = $val['goods_id'];
- $stock = true;
- // Options sku_str
- $options = $val['sku_str'];
-
-
- $goods_query_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_goods as p left join ".C('DB_PREFIX')."lionfish_comshop_good_commiss as pd
- on p.id = pd.goods_id where p.id ={$goods_id} ";
-
- $goods_query_arr = M()->query($goods_query_sql);
- $goods_query = $goods_query_arr[0];
-
- $goods_query['model'] = $goods_query['codes'];
-
- if ($goods_query) {
- $option_price = null;
- $option_weight = $goods_query['weight'];
- $option_data = array();
-
- $max_quantity = $goods_query['total'];
- if (!empty($options)) {
-
- $goods_option_mult_value = M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' => $goods_id,'option_item_ids' => $options) )->find();
-
-
- $goods_option_mult_value['pin_price'] = $goods_option_mult_value['pinprice'];
- $goods_option_mult_value['dan_price'] = $goods_option_mult_value['marketprice'];
- $goods_option_mult_value['costprice'] = $goods_option_mult_value['costprice'];
- $goods_query['card_price'] = $goods_option_mult_value['card_price'];
- $goods_query['costprice'] = $goods_option_mult_value['costprice'];
- $goods_query['model'] = $goods_option_mult_value['goodssn'];
-
-
- $options_arr = array();
- $option_value_id_arr = explode('_', $options);
- foreach ($option_value_id_arr as $id_val) {
- $goods_option_value = M('lionfish_comshop_goods_option_item')->where( array('goods_id' => $goods_id,'id' => $id_val) )->find();
- $options_arr[$goods_option_value['goods_option_id']] = $goods_option_value['id'];
- }
- }
- $option_value_image = '';
- if($options_arr){
- foreach ($options_arr as $goods_option_id => $goods_option_item_id ) {
- //option_value
- $option_query = M('lionfish_comshop_goods_option')->where( array('goods_id' => $goods_id,'id' => $goods_option_id) )->find();
-
- if ($option_query) {
-
- $option_value_query = M('lionfish_comshop_goods_option_item')->where( array('id' => $goods_option_item_id,'goods_id' => $goods_id) )->find();
-
- if ($option_value_query) {
-
- if( !empty($option_value_query['thumb']) )
- {
- $option_value_image = $option_value_query['thumb'];
- }
-
- $max_quantity = $goods_option_mult_value['stock'];
-
- //根据商品类型获取不同价格 begin pinprice pin_price productprice dan_price
- if ($buy_type == 'pintuan' && $goods_query['type'] != 'spike') {
- $option_price = $goods_option_mult_value['pin_price'];
- }else if($goods_query['type'] == 'spike')
- {
- $option_price = $goods_option_mult_value['dan_price'];
- }
- else {
- $option_price = $goods_option_mult_value['dan_price'];
- }
- //根据商品类型获取不同价格 begin
- $option_weight = $goods_option_mult_value['weight'];
- $costprice = $goods_option_mult_value['costprice'];
- $option_data[] = array(
- 'goods_option_id' => $goods_option_id,
- 'goods_option_value_id' => $goods_option_item_id,
- 'option_id' => $goods_option_id,
- 'option_value_id' => $goods_option_item_id,
- 'name' => $option_query['title'],
- 'value' => $option_value_query['title'],
- 'quantity' => $quantity,
- 'price' => $option_price,
- 'card_price' => $goods_option_mult_value['card_price'],
- 'costprice' => $costprice,
- 'weight' => $option_weight,
- );
- }
- }
- }
- }
-
-
- $header_disc = 100;
- $shop_price = $goods_query['productprice'];
-
- $goods_query['price'] = $goods_query['price'];
-
- $thumb_image = D('Home/Pingoods')->get_goods_images($goods_id);
-
- if( !empty($thumb_image) )
- {
- $thumb_image = tomedia($thumb_image['image']);
- }
-
-
- if(!empty($option_value_image))
- {
- $thumb_image = tomedia($option_value_image);
- }
-
- $store_info = array('s_true_name' => '');
- $s_logo = D('Seller/Front')->get_config_by_name('shoplogo');
-
- if( !empty($s_logo) )
- {
- $s_logo = tomedia($s_logo);
- }
-
-
- //$goods_query['price']
-
- if ( !is_null($option_price)) {
- $goods_query['price'] = $option_price;
- } else {
- //根据商品类型获取不同价格 begin
- if ($buy_type == 'pintuan') {//判断类型是否是积分商品
- if($goods_query['type'] == 'integral')
- {
- //TODO....等待打开积分
- //$intgral_goods_info = M('intgral_goods')->field('score')->where( array('goods_id' => $goods_id) )->find();
- //$goods_query['price'] = $intgral_goods_info['score'];
- }
- else if($goods_query['type'] == 'spike')
- {
-
- }
- else{
-
- if($goods_query['type'] == 'pin')
- {
- //ims_
- $pin_goods = M('lionfish_comshop_good_pin')->where( array('goods_id' => $goods_id) )->find();
-
-
- $goods_query['price'] = $pin_goods['pinprice'];
- }
- }
-
- }
- //根据商品类型获取不同价格 begin
-
- }
- if (!empty($option_weight)) {
- $goods_query['weight'] = $option_weight;
- }
- //拼团才会有pin_id
- $pin_id = 0;
- if ($buy_type == 'pintuan' && isset($val['pin_id'])) {
- $pin_id = $val['pin_id'];
- }
- $price = $goods_query['price'];
- //判断是否有团长折扣 暂时屏蔽 TODO.....
- /**
- if( $buy_type == 'pin' && $pin_id == 0 && $goods_query['head_disc'] != 100)
- {
- $price = round(( $price * intval($goods_query['head_disc']) )/100,2);
- $header_disc = intval($goods_query['head_disc']);
- }
- **/
-
- //判断是否会员折扣 TODO。。。先关闭
- $level_info = array('member_discount' => 100,'level_name' =>'');
-
- $member_info = M('lionfish_comshop_member')->field('level_id')->where( array('member_id' => $member_id) )->find();
- //修改商品独立会员等级折扣设置 2020.05.11
- $goods_common = M('lionfish_comshop_good_common')->field('is_mb_level_buy,has_mb_level_buy,mb_level_buy_list,packing_free,goods_start_count')->where( array('goods_id' => $goods_id ) )->find();
- $goods_query['is_mb_level_buy'] = 0;
- $goods_query['levelprice'] = 0;
- $goods_query['goods_start_count'] = $goods_common['goods_start_count'];
-
- if( $buy_type == 'dan' || $buy_type == 'soitaire' )
- {
- //商品独立会员等级折扣 begin 关闭会员折扣
- if($member_info['level_id'] > 0 && $goods_common['has_mb_level_buy'] == 1 && $goods_common['is_mb_level_buy'] == 1 && $buy_type != 'pesale' ){
- $member_level_info = M('lionfish_comshop_member_level')->where( array('id' => $member_info['level_id'] ) )->find();
- $mb_level_buy_list = unserialize($goods_common['mb_level_buy_list']);
- $mb_level_discount_list = array();
- foreach($mb_level_buy_list as $k=>$v){
- $mb_level_discount_list[$v['level_id']] = $v['discount'];
- }
- if(isset($mb_level_discount_list[$member_info['level_id']]) && !empty($mb_level_discount_list[$member_info['level_id']])){
- $level_info['member_discount'] = $mb_level_discount_list[$member_info['level_id']];
- }else{
- $level_info['member_discount'] = 0;
- }
-
- if($level_info['member_discount']>0 && $level_info['member_discount'] <100)
- {
- $level_info['level_name'] = $member_level_info['levelname'];
- if($level_info['member_discount'] == 0){
- $price2 = round( $price,2);
- }else{
- $price2 = round(( $price * $mb_level_discount_list[$member_info['level_id']] )/100,2);
- }
- $goods_query['is_mb_level_buy'] = 1;
- $goods_query['levelprice'] = $price2;
- //商品独立会员等级折扣 end
- }
- }else{
- //预售不参与会员等级折扣
- if($member_info['level_id'] > 0 && $goods_common['is_mb_level_buy'] == 1 && $buy_type != 'pesale')
- {
- $member_level_info = M('lionfish_comshop_member_level')->where( array('id' => $member_info['level_id'] ) )->find();
- $level_info['member_discount'] = $member_level_info['discount'] ;
-
- if( $level_info['member_discount'] > 0 && $level_info['member_discount'] < 100 )
- {
- $level_info['level_name'] = $member_level_info['levelname'];
- $price2 = round(( $price * $member_level_info['discount'] )/100,2);
- $goods_query['is_mb_level_buy'] = 1;
- $goods_query['levelprice'] = $price2;
- //$goods_query['price'] = $price2 ;
- //$price = $price2;//['price'];
- }
-
- }
- }
- }
-
-
- //判断商品能否参与满减活动 fullreduction_money
- $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
- $can_man_jian = 0;
- //预售不参与满减
- if( $buy_type == 'pesale')
- {
- $is_open_fullreduction = 0;
- }
-
- if( $buy_type == 'dan' || $buy_type == 'soitaire' || $buy_type == 'virtualcard' )
- {
- if( !empty($is_open_fullreduction) && $is_open_fullreduction == 1)
- {
- $gd_full_info = D('Home/Front')->get_goods_common_field($goods_id , 'is_take_fullreduction,supply_id,is_new_buy');
- $is_take_fullreduction = $gd_full_info['is_take_fullreduction'];
-
- //supply_id
- if( $gd_full_info['supply_id'] > 0)
- {
-
- $supply_info = M('lionfish_comshop_supply')->field('type')->where( array('id' => $gd_full_info['supply_id'] ) )->find();
-
-
- if(!empty($supply_info) && $supply_info['type'] == 1)
- {
- $can_man_jian = 0;
- }else{
-
- if( $is_take_fullreduction == 1 )
- {
- $can_man_jian = 1;
- }
- }
- }else{
- if( $is_take_fullreduction == 1 )
- {
- $can_man_jian = 1;
- }
- }
- $is_new_buy = $gd_full_info['is_new_buy'];
- }
- }
-
-
- $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
-
- $is_only_express = 0;
-
- if( !empty($is_open_only_express) && $is_open_only_express == 1)
- {
- $gd_s_info = D('Home/Front')->get_goods_common_field($goods_id , 'is_only_express');
- $is_only_express = $gd_s_info['is_only_express'];
- }
-
- if( $is_only_express == 0 )
- {
- $gd_s_info = D('Home/Front')->get_goods_common_field($goods_id , 'is_only_distribution,supply_id,is_only_hexiao');
- $is_only_distribution = $gd_s_info['is_only_distribution'];
- $isopen_localtown_delivery = D('Home/Front')->get_config_by_name('isopen_localtown_delivery');
- if($gd_s_info['supply_id'] > 0){
- $isopen_supply_localtown_delivery = D('Home/Front')->get_supply_config_by_name('isopen_localtown_delivery',$gd_s_info['supply_id']);
- if( $is_only_distribution == 1 && $isopen_localtown_delivery == 1 && $isopen_supply_localtown_delivery == 1)
- {
- $is_only_express = 3;
- }
- }else{
- if( $is_only_distribution == 1 && $isopen_localtown_delivery == 1)
- {
- $is_only_express = 3;
- }
- }
- if($gd_s_info['is_only_hexiao'] == 1){
- $is_only_express = 2;
- }
- }
-
- // $is_open_vipcard_buy
- if( $is_open_vipcard_buy == 1 && $goods_query['is_take_vipcard'] == 1 )
- {
-
- }else{
- $goods_query['is_take_vipcard'] = 0;
- }
- //拼团 end
- //begin 检测是否校验组件
- $isTradeComponts = D('Seller/MpModifyTradeComponts')->checkGoodsIsTradeComponts( $goods_id );
- //end 检测是否校验组件
- $this->data[$key] = array(
- 'key' => $val_uns['carkey'],
- 'goods_id' => $goods_id ,
- 'is_only_express' => $is_only_express,
- 'name' => $goods_query['goodsname'],
- 'seller_name' => $store_info['s_true_name'],
- 'seller_logo' => $s_logo,
- 'weight' => $option_weight,
- 'singledel' => $val['singledel'],
- //$val['singledel']
- 'can_man_jian' => $can_man_jian,
- 'header_disc' => $header_disc,
- 'member_disc' => $level_info['member_discount'],
- 'level_name' => $level_info['level_name'],
- 'pin_id' => $pin_id,
- 'shipping' => $goods_query['dispatchtype'],
- 'goods_freight' => $goods_query['dispatchprice'],
- 'transport_id' => $goods_query['dispatchid'],
- 'image' => $thumb_image,
- 'quantity' => $quantity,
- 'max_quantity' => $max_quantity,
- 'shop_price' => $shop_price,
- 'price' => $goods_query['price'],
- 'costprice' => $goods_query['costprice'],
- 'levelprice' => $goods_query['levelprice'],
- 'card_price' => $goods_query['card_price'],
- 'total' => round( ($price) * $quantity , 2),
- 'level_total' => round( $goods_query['levelprice'] * $quantity , 2),
- 'card_total' => round($goods_query['card_price'] * $quantity ,2),
- 'is_take_vipcard' => $goods_query['is_take_vipcard'],
- 'is_mb_level_buy' => $goods_query['is_mb_level_buy'],
- 'model' => $goods_query['model'],
- 'option' => $option_data,
- 'sku_str' => $val['sku_str'],
- 'soli_id' => isset($val['soli_id']) ? intval($val['soli_id']) : 0,
- 'is_new_buy' => $is_new_buy,
- 'packing_free' => $goods_common['packing_free'],
- 'goods_start_count' => $goods_query['goods_start_count'],
- 'isTradeComponts' => $isTradeComponts,//是否参与交易组件
- );
-
-
-
- } else {
- $this->removecar($key,$token);
- }
- }
- }
-
-
- return $this->data;
- }
-
- //删除商品
- public function removecar($key,$token) {
-
- $key = $key; //重新给$key赋值
-
- M('lionfish_comshop_car')->where( array('token' => $token,'carkey' => $key) )->delete();
- }
-
- //购物车是否为空
- public function has_goodswecar($buy_type = 'dan', $token, $community_id) {
-
-
- if ($buy_type == 'dan') {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id='{$community_id}' and carkey like 'cart.%' ";
- $s = M()->query($cart_sql);
-
- }
- else if( $buy_type == 'pindan' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'pindancart.%' ";
- $s = M()->query($cart_sql);
-
- }else if( $buy_type == 'pintuan' )
- {
-
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'pintuancart.%' ";
- $s = M()->query($cart_sql);
- }
-
- else if( $buy_type == 'soitaire' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'soitairecart.%' ";
- $s = M()->query($cart_sql);
- }
- else if( $buy_type == 'presale' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'presalecart.%' ";
- $s = M()->query($cart_sql);
- }
- else if( $buy_type == 'virtualcard' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'virtualcardcart.%' ";
- $s = M()->query($cart_sql);
- }
-
- else if( $buy_type == 'integral' )
- {
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'integralcart.%' ";
- $s = M()->query($cart_sql);
- }
- else if ($buy_type == 'pin') {
-
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'cart_activity.%' ";
- $s = M()->query($cart_sql);
- }
- return count($s);
- }
-
-
- public function count_activitycar($token) {
-
- $quantity = 0;
-
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'cart_activity.%' ";
- $cart = M()->query($cart_sql);
-
- foreach ($cart as $key => $val) {
- $format_data = unserialize($val['format_data']);
- $quantity += $format_data['quantity'];
- }
- return $quantity;
- }
-
- public function removeActivityAllcar($token ,$car_prefix='pindancart.') {
-
- M('lionfish_comshop_car')->where(" token = '{$token}' and carkey like '".$car_prefix."%' ")->delete();
- }
-
- public function count_goodscar($token, $community_id) {
-
- $quantity = 0;
-
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and community_id='{$community_id}' and carkey like 'cart.%' ";
- $cart = M()->query($cart_sql);
-
-
- foreach ($cart as $key => $val) {
- $format_data = unserialize($val['format_data']);
- if(isset($format_data['quantity']))
- $quantity += $format_data['quantity'];
- }
-
- return $quantity;
- }
- /**
- * @author cy 2020-12-07
- * @desc 获取会员购物车中新人专享商品种类数
- * @param $token
- * @param $gid 商品id
- * @param $sku_str 商品规格id
- * @return int
- */
- public function get_new_goods_count($token,$gid,$sku_str){
- $count = 0;
- $cart_sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_car
- where token='{$token}' and carkey like 'cart.%' ";
- $cart = M()->query($cart_sql);
- foreach ($cart as $key => $val) {
- $format_data = unserialize($val['format_data']);
- $goods_id = $format_data['goods_id'];
- $goods_description = D('Home/Front')->get_goods_common_field($goods_id , 'is_new_buy');
- if( !empty($goods_description['is_new_buy']) && $goods_description['is_new_buy'] == 1){
- if($goods_id != $gid){
- $count++;
- }else{
- if(!empty($sku_str) && $sku_str != $format_data['sku_str']){
- $count++;
- }
- }
- }
- }
- return $count;
- }
-
- }
|