Example #1
0
 private function checkStore()
 {
     if (!uk86_checkPlatformStore()) {
         // 是否到达商品数上限
         $goods_num = Model('goods')->getGoodsCommonCount(array('store_id' => $_SESSION['store_id']));
         if (intval($this->store_grade['sg_goods_limit']) != 0) {
             if ($goods_num >= $this->store_grade['sg_goods_limit']) {
                 uk86_showMessage(L('store_goods_index_goods_limit') . $this->store_grade['sg_goods_limit'] . L('store_goods_index_goods_limit1'), 'index.php?act=store_goods&op=goods_list', 'html', 'error');
             }
         }
     }
 }
Example #2
0
 /**
  * 关联版式添加
  */
 public function plate_addOp()
 {
     if (uk86_chksubmit()) {
         // 验证表单
         $obj_validate = new Uk86Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["p_name"], "require" => "true", "message" => '请填写版式名称'), array("input" => $_POST["p_content"], "require" => "true", "message" => '请填写版式内容'));
         $error = $obj_validate->uk86_validate();
         if ($error != '') {
             showDialog(L('error') . $error, uk86_urlShop('store_plate', 'index'));
         }
         $insert = array();
         $insert['plate_name'] = $_POST['p_name'];
         $insert['plate_position'] = $_POST['p_position'];
         $insert['plate_content'] = $_POST['p_content'];
         $insert['store_id'] = $_SESSION['store_id'];
         $result = Model('store_plate')->addStorePlate($insert);
         if ($result) {
             showDialog(L('nc_common_op_succ'), uk86_urlShop('store_plate', 'index'), 'succ');
         } else {
             showDialog(L('nc_common_op_fail'), uk86_urlShop('store_plate', 'index'));
         }
     }
     // 是否能使用编辑器
     if (uk86_checkPlatformStore()) {
         // 平台店铺可以使用编辑器
         $editor_multimedia = true;
     } else {
         // 三方店铺需要
         $editor_multimedia = false;
         if ($this->store_grade['sg_function'] == 'editor_multimedia') {
             $editor_multimedia = true;
         }
     }
     Tpl::output('editor_multimedia', $editor_multimedia);
     $this->profile_menu('plate_add', 'plate_add');
     Tpl::showpage('store_plate.add');
 }
Example #3
0
 /**
  * 添加虚拟抢购页面
  */
 public function groupbuy_add_vrOp()
 {
     $model_groupbuy_quota = Model('groupbuy_quota');
     if (uk86_checkPlatformStore()) {
         Tpl::output('isOwnShop', true);
     } else {
         $current_groupbuy_quota = $model_groupbuy_quota->getGroupbuyQuotaCurrent($_SESSION['store_id']);
         if (empty($current_groupbuy_quota)) {
             uk86_showMessage('当前没有可用套餐,请先购买套餐', uk86_urlShop('store_groupbuy', 'groupbuy_quota_add'), '', 'error');
         }
         Tpl::output('current_groupbuy_quota', $current_groupbuy_quota);
     }
     // 根据后台设置的审核期重新设置抢购开始时间
     Tpl::output('groupbuy_start_time', TIMESTAMP + intval(C('groupbuy_review_day')) * 86400);
     // 虚拟抢购分类
     // Tpl::output('groupbuy_vr_classes', Model('groupbuy')->getGroupbuyVrClasses());
     $model_vr_groupbuy_class = Model('vr_groupbuy_class');
     $classlist = $model_vr_groupbuy_class->getVrGroupbuyClassList(array('parent_class_id' => 0));
     Tpl::output('classlist', $classlist);
     // 虚拟区域分类
     // Tpl::output('groupbuy_vr_cities', Model('groupbuy')->getGroupbuyVrCities());
     $model_vr_groupbuy_area = Model('vr_groupbuy_area');
     $arealist = $model_vr_groupbuy_area->getVrGroupbuyAreaList(array('parent_area_id' => 0, 'hot_city' => 1), '', '100');
     Tpl::output('arealist', $arealist);
     self::profile_menu('groupbuy_add_vr');
     Tpl::showpage('store_groupbuy.add_vr');
 }
Example #4
0
 /**
  * 商户中心首页
  */
 public function indexOp()
 {
     Uk86Language::uk86_read('member_home_index');
     // 店铺信息
     $store_info = $this->store_info;
     if (intval($store_info['store_end_time']) > 0) {
         $store_info['store_end_time_text'] = date('Y-m-d', $store_info['store_end_time']);
         $reopen_time = $store_info['store_end_time'] - 3600 * 24 + 1 - TIMESTAMP;
         if (!uk86_checkPlatformStore() && $store_info['store_end_time'] - TIMESTAMP >= 0 && $reopen_time < 2592000) {
             //到期续签提醒(<30天)
             $store_info['reopen_tip'] = true;
         }
     } else {
         $store_info['store_end_time_text'] = L('store_no_limit');
     }
     // 店铺等级信息
     $store_info['grade_name'] = $this->store_grade['sg_name'];
     $store_info['grade_goodslimit'] = $this->store_grade['sg_goods_limit'];
     $store_info['grade_albumlimit'] = $this->store_grade['sg_album_limit'];
     Tpl::output('store_info', $store_info);
     // 商家帮助
     $model_help = Model('help');
     $condition = array();
     $condition['help_show'] = '1';
     //是否显示,0为否,1为是
     $help_list = $model_help->getStoreHelpTypeList($condition, '', 6);
     Tpl::output('help_list', $help_list);
     // 销售情况统计
     $field = ' COUNT(*) as ordernum,SUM(order_amount) as orderamount ';
     $where = array();
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     // 昨日销量
     $where['order_add_time'] = array('between', array(strtotime(date('Y-m-d', time() - 3600 * 24)), strtotime(date('Y-m-d', time())) - 1));
     $daily_sales = Model('stat')->getoneByStatorder($where, $field);
     Tpl::output('daily_sales', $daily_sales);
     // 月销量
     $where['order_add_time'] = array('gt', strtotime(date('Y-m', time())));
     $monthly_sales = Model('stat')->getoneByStatorder($where, $field);
     Tpl::output('monthly_sales', $monthly_sales);
     unset($field, $where);
     //单品销售排行
     //最近30天
     $stime = strtotime(date('Y-m-d', time() - 3600 * 24)) - 86400 * 29;
     //30天前
     $etime = strtotime(date('Y-m-d', time())) - 1;
     //昨天23:59
     $where = array();
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['order_add_time'] = array('between', array($stime, $etime));
     $field = ' goods_id,goods_name,SUM(goods_num) as goodsnum,goods_image ';
     $orderby = 'goodsnum desc,goods_id';
     $goods_list = Model('stat')->statByStatordergoods($where, $field, 0, 8, $orderby, 'goods_id');
     unset($stime, $etime, $where, $field, $orderby);
     Tpl::output('goods_list', $goods_list);
     if (!uk86_checkPlatformStore()) {
         if (C('groupbuy_allow') == 1) {
             // 抢购套餐
             $groupquota_info = Model('groupbuy_quota')->getGroupbuyQuotaCurrent($_SESSION['store_id']);
             Tpl::output('groupquota_info', $groupquota_info);
         }
         if (intval(C('promotion_allow')) == 1) {
             // 限时折扣套餐
             $xianshiquota_info = Model('p_xianshi_quota')->getXianshiQuotaCurrent($_SESSION['store_id']);
             Tpl::output('xianshiquota_info', $xianshiquota_info);
             // 满即送套餐
             $mansongquota_info = Model('p_mansong_quota')->getMansongQuotaCurrent($_SESSION['store_id']);
             Tpl::output('mansongquota_info', $mansongquota_info);
             // 优惠套装套餐
             $binglingquota_info = Model('p_bundling')->getBundlingQuotaInfoCurrent($_SESSION['store_id']);
             Tpl::output('binglingquota_info', $binglingquota_info);
             // 推荐展位套餐
             $boothquota_info = Model('p_booth')->getBoothQuotaInfoCurrent($_SESSION['store_id']);
             Tpl::output('boothquota_info', $boothquota_info);
         }
         if (C('voucher_allow') == 1) {
             $voucherquota_info = Model('voucher')->getCurrentQuota($_SESSION['store_id']);
             Tpl::output('voucherquota_info', $voucherquota_info);
         }
     } else {
         Tpl::output('isOwnShop', true);
     }
     $phone_array = explode(',', C('site_phone'));
     Tpl::output('phone_array', $phone_array);
     Tpl::output('menu_sign', 'index');
     Tpl::showpage('index');
 }
 /**
  * 保存添加的满就送活动
  **/
 public function mansong_saveOp()
 {
     $mansong_name = trim($_POST['mansong_name']);
     $start_time = strtotime($_POST['start_time']);
     $end_time = strtotime($_POST['end_time']);
     $model_mansong_quota = Model('p_mansong_quota');
     $model_mansong = Model('p_mansong');
     $model_mansong_rule = Model('p_mansong_rule');
     if ($start_time >= $end_time) {
         showDialog(Uk86Language::uk86_get('greater_than_start_time'));
     }
     if (empty($mansong_name)) {
         showDialog(Uk86Language::uk86_get('mansong_name_error'));
     }
     $start_time_limit = $model_mansong->getMansongNewStartTime($_SESSION['store_id']);
     if (!empty($start_time_limit) && $start_time_limit > $start_time) {
         $start_time = $start_time_limit;
     }
     if (!uk86_checkPlatformStore()) {
         //检查当前套餐是否可用
         $current_mansong_quota = $model_mansong_quota->getMansongQuotaCurrent($_SESSION['store_id']);
         if (empty($current_mansong_quota)) {
             showDialog(Uk86Language::uk86_get('mansong_quota_current_error'), 'reload', 'error');
         }
         //验证输入
         $quota_start_time = intval($current_mansong_quota['start_time']);
         $quota_end_time = intval($current_mansong_quota['end_time']);
         if ($start_time < $quota_start_time) {
             showDialog(sprintf(Uk86Language::uk86_get('mansong_add_start_time_explain'), date('Y-m-d', $current_mansong_quota['start_time'])));
         }
         if ($end_time > $quota_end_time) {
             showDialog(sprintf(Uk86Language::uk86_get('mansong_add_end_time_explain'), date('Y-m-d', $current_mansong_quota['end_time'])));
         }
     }
     if (empty($_POST['mansong_rule'])) {
         showDialog('满即送规则不能为空');
     }
     $param = array();
     $param['mansong_name'] = $mansong_name;
     $param['start_time'] = $start_time;
     $param['end_time'] = $end_time;
     $param['store_id'] = $_SESSION['store_id'];
     $param['store_name'] = $_SESSION['store_name'];
     $param['member_id'] = $_SESSION['member_id'];
     $param['member_name'] = $_SESSION['member_name'];
     $param['quota_id'] = $current_mansong_quota['quota_id'] ? $current_mansong_quota['quota_id'] : 0;
     $param['remark'] = trim($_POST['remark']);
     $mansong_id = $model_mansong->addMansong($param);
     if ($mansong_id) {
         $mansong_rule_array = array();
         foreach ($_POST['mansong_rule'] as $value) {
             list($price, $discount, $goods_id) = explode(',', $value);
             $mansong_rule = array();
             $mansong_rule['mansong_id'] = $mansong_id;
             $mansong_rule['price'] = $price;
             $mansong_rule['discount'] = $discount;
             $mansong_rule['goods_id'] = $goods_id;
             $mansong_rule_array[] = $mansong_rule;
         }
         //生成规则
         $result = $model_mansong_rule->addMansongRuleArray($mansong_rule_array);
         $this->recordSellerLog('添加满即送活动,活动名称:' . $mansong_name);
         // 自动发布动态
         // mansong_name,start_time,end_time,store_id
         $data_array = array();
         $data_array['mansong_name'] = $param['mansong_name'];
         $data_array['start_time'] = $param['start_time'];
         $data_array['end_time'] = $param['end_time'];
         $data_array['store_id'] = $_SESSION['store_id'];
         $this->storeAutoShare($data_array, 'mansong');
         showDialog(Uk86Language::uk86_get('mansong_add_success'), uk86_urlShop('store_promotion_mansong', 'mansong_list'), 'succ');
     } else {
         showDialog(Uk86Language::uk86_get('mansong_add_fail'));
     }
 }
Example #6
0
 /**
  * 记录店铺费用
  *
  * @param $cost_price 费用金额
  * @param $cost_remark 费用备注
  */
 protected function recordStoreCost($cost_price, $cost_remark)
 {
     // 平台店铺不记录店铺费用
     if (uk86_checkPlatformStore()) {
         return false;
     }
     $model_store_cost = Model('store_cost');
     $param = array();
     $param['cost_store_id'] = $_SESSION['store_id'];
     $param['cost_seller_id'] = $_SESSION['seller_id'];
     $param['cost_price'] = $cost_price;
     $param['cost_remark'] = $cost_remark;
     $param['cost_state'] = 0;
     $param['cost_time'] = TIMESTAMP;
     $model_store_cost->addStoreCost($param);
     // 发送店铺消息
     $param = array();
     $param['code'] = 'store_cost';
     $param['store_id'] = $_SESSION['store_id'];
     $param['param'] = array('price' => $cost_price, 'seller_name' => $_SESSION['seller_name'], 'remark' => $cost_remark);
     Uk86QueueClient::push('sendStoreMsg', $param);
 }
Example #7
0
 /**
  * 用户中心右边,小导航
  *
  * @param string	$menu_type	导航类型
  * @param string 	$menu_key	当前导航的menu_key
  * @param array 	$array		附加菜单
  * @return
  */
 private function profile_menu($menu_type, $menu_key = '', $array = array())
 {
     Uk86Language::uk86_read('member_layout');
     $lang = Uk86Language::uk86_getLangContent();
     $menu_array = array();
     switch ($menu_type) {
         case 'index':
             $menu_array[] = array('menu_key' => 'bind_class', 'menu_name' => $lang['nc_member_path_bind_class'], 'menu_url' => 'index.php?act=store_info&op=bind_class');
             if (!uk86_checkPlatformStore()) {
                 $menu_array[] = array('menu_key' => 'index', 'menu_name' => $lang['nc_member_path_store_info'], 'menu_url' => 'index.php?act=store_info&op=index');
                 $menu_array[] = array('menu_key' => 'reopen', 'menu_name' => $lang['nc_member_path_store_reopen'], 'menu_url' => 'index.php?act=store_info&op=reopen');
             }
             break;
         case 'bind_class':
             $menu_array = array(array('menu_key' => 'index', 'menu_name' => $lang['nc_member_path_bind_class'], 'menu_url' => 'index.php?act=store_bind_class&op=index'));
             break;
         case 'add':
             $menu_array = array(array('menu_key' => 'index', 'menu_name' => $lang['nc_member_path_bind_class'], 'menu_url' => 'index.php?act=store_bind_class&op=index'), array('menu_key' => 'add', 'menu_name' => $lang['nc_member_path_bind_class_add'], 'menu_url' => 'index.php?act=store_bind_class&op=add'));
             break;
     }
     if (!empty($array)) {
         $menu_array[] = $array;
     }
     Tpl::output('member_menu', $menu_array);
     Tpl::output('menu_key', $menu_key);
 }
Example #8
0
echo $lang['store_validity'] . $lang['nc_colon'];
?>
<strong><?php 
echo $output['store_info']['store_end_time_text'];
?>
          <?php 
if ($output['store_info']['reopen_tip']) {
    ?>
          <a href="index.php?act=store_info&op=reopen">马上续签</a>
          <?php 
}
?>
          </strong> </dd>
      </dl>
<?php 
if (!uk86_checkPlatformStore()) {
    ?>
      <div class="detail-rate">
        <h5> <strong><?php 
    echo $lang['store_dynamic_evaluation'] . $lang['nc_colon'];
    ?>
</strong> 与行业相比 </h5>
        <ul>
          <?php 
    foreach ($output['store_info']['store_credit'] as $value) {
        ?>
          <li> <?php 
        echo $value['text'];
        ?>
<span class="credit"><?php 
        echo $value['credit'];
 /**
  * 保存添加的限时折扣活动
  **/
 public function xianshi_saveOp()
 {
     //验证输入
     $xianshi_name = trim($_POST['xianshi_name']);
     $start_time = strtotime($_POST['start_time']);
     $end_time = strtotime($_POST['end_time']);
     $lower_limit = intval($_POST['lower_limit']);
     if ($lower_limit <= 0) {
         $lower_limit = 1;
     }
     if (empty($xianshi_name)) {
         showDialog(Uk86Language::uk86_get('xianshi_name_error'));
     }
     if ($start_time >= $end_time) {
         showDialog(Uk86Language::uk86_get('greater_than_start_time'));
     }
     if (!uk86_checkPlatformStore()) {
         //获取当前套餐
         $model_xianshi_quota = Model('p_xianshi_quota');
         $current_xianshi_quota = $model_xianshi_quota->getXianshiQuotaCurrent($_SESSION['store_id']);
         if (empty($current_xianshi_quota)) {
             showDialog('没有可用限时折扣套餐,请先购买套餐');
         }
         $quota_start_time = intval($current_xianshi_quota['start_time']);
         $quota_end_time = intval($current_xianshi_quota['end_time']);
         if ($start_time < $quota_start_time) {
             showDialog(sprintf(Uk86Language::uk86_get('xianshi_add_start_time_explain'), date('Y-m-d', $current_xianshi_quota['start_time'])));
         }
         if ($end_time > $quota_end_time) {
             showDialog(sprintf(Uk86Language::uk86_get('xianshi_add_end_time_explain'), date('Y-m-d', $current_xianshi_quota['end_time'])));
         }
     }
     //生成活动
     $model_xianshi = Model('p_xianshi');
     $param = array();
     $param['xianshi_name'] = $xianshi_name;
     $param['xianshi_title'] = $_POST['xianshi_title'];
     $param['xianshi_explain'] = $_POST['xianshi_explain'];
     $param['quota_id'] = $current_xianshi_quota['quota_id'] ? $current_xianshi_quota['quota_id'] : 0;
     $param['start_time'] = $start_time;
     $param['end_time'] = $end_time;
     $param['store_id'] = $_SESSION['store_id'];
     $param['store_name'] = $_SESSION['store_name'];
     $param['member_id'] = $_SESSION['member_id'];
     $param['member_name'] = $_SESSION['member_name'];
     $param['lower_limit'] = $lower_limit;
     $result = $model_xianshi->addXianshi($param);
     if ($result) {
         $this->recordSellerLog('添加限时折扣活动,活动名称:' . $xianshi_name . ',活动编号:' . $result);
         // 添加计划任务
         $this->addcron(array('exetime' => $param['end_time'], 'exeid' => $result, 'type' => 7), true);
         showDialog(Uk86Language::uk86_get('xianshi_add_success'), self::LINK_XIANSHI_MANAGE . $result, 'succ', '', 3);
     } else {
         showDialog(Uk86Language::uk86_get('xianshi_add_fail'));
     }
 }
 /**
  * 编辑商品保存
  */
 public function edit_save_goodsOp()
 {
     $common_id = intval($_POST['commonid']);
     if (!uk86_chksubmit() || $common_id <= 0) {
         showDialog(L('store_goods_index_goods_edit_fail'), uk86_urlShop('store_goods_online', 'index'));
     }
     // 验证表单
     $obj_validate = new Uk86Validate();
     $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null')));
     $error = $obj_validate->uk86_validate();
     if ($error != '') {
         showDialog(L('error') . $error, uk86_urlShop('store_goods_online', 'index'));
     }
     $gc_id = intval($_POST['cate_id']);
     // 验证商品分类是否存在且商品分类是否为最后一级
     $data = Model('goods_class')->getGoodsClassForCacheModel();
     if (!isset($data[$gc_id]) || isset($data[$gc_id]['child']) || isset($data[$gc_id]['childchild'])) {
         showDialog(L('store_goods_index_again_choose_category1'));
     }
     // 三方店铺验证是否绑定了该分类
     if (!uk86_checkPlatformStore()) {
         //商品分类 by ukshop. com 提供批量显示所有分类插件
         $model_bind_class = Model('store_bind_class');
         $goods_class = Model('goods_class')->getGoodsClassForCacheModel();
         $where['store_id'] = $_SESSION['store_id'];
         $class_2 = $goods_class[$gc_id]['gc_parent_id'];
         $class_1 = $goods_class[$class_2]['gc_parent_id'];
         $where['class_1'] = $class_1;
         $where['class_2'] = $class_2;
         $where['class_3'] = $gc_id;
         $bind_info = $model_bind_class->getStoreBindClassInfo($where);
         if (empty($bind_info)) {
             $where['class_3'] = 0;
             $bind_info = $model_bind_class->getStoreBindClassInfo($where);
             if (empty($bind_info)) {
                 $where['class_2'] = 0;
                 $where['class_3'] = 0;
                 $bind_info = $model_bind_class->getStoreBindClassInfo($where);
                 if (empty($bind_info)) {
                     $where['class_1'] = 0;
                     $where['class_2'] = 0;
                     $where['class_3'] = 0;
                     $bind_info = $model_bind_class->getStoreBindClassInfo($where);
                     if (empty($bind_info)) {
                         showDialog(L('store_goods_index_again_choose_category2'));
                     }
                 }
             }
         }
     }
     // 分类信息
     $goods_class = Model('goods_class')->getGoodsClassLineForTag(intval($_POST['cate_id']));
     $model_goods = Model('goods');
     $update_common = array();
     $update_common['goods_name'] = $_POST['g_name'];
     $update_common['goods_jingle'] = $_POST['g_jingle'];
     $update_common['gc_id'] = $gc_id;
     $update_common['gc_id_1'] = intval($goods_class['gc_id_1']);
     $update_common['gc_id_2'] = intval($goods_class['gc_id_2']);
     $update_common['gc_id_3'] = intval($goods_class['gc_id_3']);
     $update_common['gc_name'] = $_POST['cate_name'];
     $update_common['brand_id'] = $_POST['b_id'];
     $update_common['brand_name'] = $_POST['b_name'];
     $update_common['type_id'] = intval($_POST['type_id']);
     $update_common['goods_image'] = $_POST['image_path'];
     $update_common['goods_price'] = floatval($_POST['g_price']);
     $update_common['goods_marketprice'] = floatval($_POST['g_marketprice']);
     $update_common['goods_costprice'] = floatval($_POST['g_costprice']);
     $update_common['goods_discount'] = floatval($_POST['g_discount']);
     $update_common['goods_serial'] = $_POST['g_serial'];
     $update_common['goods_storage_alarm'] = intval($_POST['g_alarm']);
     $update_common['store_mentioning'] = intval($_POST['g_mentioning']);
     $update_common['goods_attr'] = serialize($_POST['attr']);
     $update_common['goods_body'] = $_POST['g_body'];
     $update_common['store_floor_id'] = intval($_POST['store_floor_id']);
     //楼层id
     $update_common['store_floor_name'] = $_POST['store_floor_name'];
     //楼层名称
     // 序列化保存手机端商品描述数据
     if ($_POST['m_body'] != '') {
         $_POST['m_body'] = str_replace('&quot;', '"', $_POST['m_body']);
         $_POST['m_body'] = json_decode($_POST['m_body'], true);
         if (!empty($_POST['m_body'])) {
             $_POST['m_body'] = serialize($_POST['m_body']);
         } else {
             $_POST['m_body'] = '';
         }
     }
     $update_common['mobile_body'] = $_POST['m_body'];
     $update_common['goods_commend'] = intval($_POST['g_commend']);
     $update_common['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']);
     // 店铺关闭时,商品下架
     $update_common['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60;
     $update_common['goods_verify'] = C('goods_verify') == 1 ? 10 : 1;
     $update_common['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null);
     $update_common['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null);
     $update_common['goods_vat'] = intval($_POST['g_vat']);
     $update_common['areaid_1'] = intval($_POST['province_id']);
     $update_common['areaid_2'] = intval($_POST['city_id']);
     $update_common['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']);
     // 运费模板
     $update_common['transport_title'] = $_POST['transport_title'];
     $update_common['goods_freight'] = floatval($_POST['g_freight']);
     //查询店铺商品分类
     $goods_stcids_arr = array();
     if (!empty($_POST['sgcate_id'])) {
         $sgcate_id_arr = array();
         foreach ($_POST['sgcate_id'] as $k => $v) {
             $sgcate_id_arr[] = intval($v);
         }
         $sgcate_id_arr = array_unique($sgcate_id_arr);
         $store_goods_class = Model('store_goods_class')->getStoreGoodsClassList(array('store_id' => $_SESSION['store_id'], 'stc_id' => array('in', $sgcate_id_arr), 'stc_state' => '1'));
         if (!empty($store_goods_class)) {
             foreach ($store_goods_class as $k => $v) {
                 if ($v['stc_id'] > 0) {
                     $goods_stcids_arr[] = $v['stc_id'];
                 }
                 if ($v['stc_parent_id'] > 0) {
                     $goods_stcids_arr[] = $v['stc_parent_id'];
                 }
             }
             $goods_stcids_arr = array_unique($goods_stcids_arr);
             sort($goods_stcids_arr);
         }
     }
     if (empty($goods_stcids_arr)) {
         $update_common['goods_stcids'] = '';
     } else {
         $update_common['goods_stcids'] = ',' . implode(',', $goods_stcids_arr) . ',';
     }
     $update_common['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : '';
     $update_common['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : '';
     $update_common['is_virtual'] = intval($_POST['is_gv']);
     $update_common['virtual_indate'] = $_POST['g_vindate'] != '' ? strtotime($_POST['g_vindate']) + 24 * 60 * 60 - 1 : 0;
     // 当天的最后一秒结束
     $update_common['virtual_limit'] = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']);
     $update_common['virtual_invalid_refund'] = intval($_POST['g_vinvalidrefund']);
     $update_common['is_fcode'] = intval($_POST['is_fc']);
     $update_common['is_appoint'] = intval($_POST['is_appoint']);
     // 只有库存为零的商品可以预约
     $update_common['appoint_satedate'] = $update_common['is_appoint'] == 1 ? strtotime($_POST['g_saledate']) : '';
     // 预约商品的销售时间
     $update_common['is_presell'] = $update_common['goods_state'] == 1 ? intval($_POST['is_presell']) : 0;
     // 只有出售中的商品可以预售
     $update_common['presell_deliverdate'] = $update_common['is_presell'] == 1 ? strtotime($_POST['g_deliverdate']) : '';
     // 预售商品的发货时间
     $update_common['is_own_shop'] = in_array($_SESSION['store_id'], model('store')->getOwnShopIds()) ? 1 : 0;
     // 开始事务
     Model()->beginTransaction();
     $model_gift = Model('goods_gift');
     // 清除原有规格数据
     $model_type = Model('type');
     $model_type->delGoodsAttr(array('goods_commonid' => $common_id));
     // 生成商品二维码
     require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php';
     $PhpQRCode = new PhpQRCode();
     $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS);
     // 更新商品规格
     $goodsid_array = array();
     $colorid_array = array();
     if (is_array($_POST['spec'])) {
         foreach ($_POST['spec'] as $value) {
             $goods_info = $model_goods->getGoodsInfo(array('goods_id' => $value['goods_id'], 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id');
             if (!empty($goods_info)) {
                 $goods_id = $goods_info['goods_id'];
                 $update = array();
                 $update['goods_commonid'] = $common_id;
                 $update['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']);
                 $update['goods_jingle'] = $update_common['goods_jingle'];
                 $update['store_id'] = $_SESSION['store_id'];
                 $update['store_name'] = $_SESSION['store_name'];
                 $update['gc_id'] = $update_common['gc_id'];
                 $update['gc_id_1'] = $update_common['gc_id_1'];
                 $update['gc_id_2'] = $update_common['gc_id_2'];
                 $update['gc_id_3'] = $update_common['gc_id_3'];
                 $update['brand_id'] = $update_common['brand_id'];
                 $update['goods_price'] = $value['price'];
                 $update['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice'];
                 $update['goods_serial'] = $value['sku'];
                 $update['goods_storage_alarm'] = intval($value['alarm']);
                 $update['goods_spec'] = serialize($value['sp_value']);
                 $update['goods_storage'] = $value['stock'];
                 $update['goods_state'] = $update_common['goods_state'];
                 $update['goods_verify'] = $update_common['goods_verify'];
                 $update['goods_edittime'] = TIMESTAMP;
                 $update['areaid_1'] = $update_common['areaid_1'];
                 $update['areaid_2'] = $update_common['areaid_2'];
                 $update['color_id'] = intval($value['color']);
                 $update['transport_id'] = $update_common['transport_id'];
                 $update['goods_freight'] = $update_common['goods_freight'];
                 $update['goods_vat'] = $update_common['goods_vat'];
                 $update['goods_commend'] = $update_common['goods_commend'];
                 $update['goods_stcids'] = $update_common['goods_stcids'];
                 $update['is_virtual'] = $update_common['is_virtual'];
                 $update['virtual_indate'] = $update_common['virtual_indate'];
                 $update['virtual_limit'] = $update_common['virtual_limit'];
                 $update['virtual_invalid_refund'] = $update_common['virtual_invalid_refund'];
                 $update['is_fcode'] = $update_common['is_fcode'];
                 $update['is_appoint'] = $update_common['is_appoint'];
                 $update['is_presell'] = $update_common['is_presell'];
                 $update['store_mentioning'] = $update_common['store_mentioning'];
                 $update['store_floor_id'] = $update_common['store_floor_id'];
                 //楼层id
                 $update['store_floor_name'] = $update_common['store_floor_name'];
                 //楼层名称
                 // 虚拟商品不能有赠品
                 if ($update_common['is_virtual'] == 1) {
                     $update['have_gift'] = 0;
                     $model_gift->delGoodsGift(array('goods_id' => $goods_id));
                 }
                 $update['is_own_shop'] = $update_common['is_own_shop'];
                 $model_goods->editGoodsById($update, $goods_id);
                 // 生成商品二维码
                 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id);
                 $PhpQRCode->set('pngTempName', $goods_id . '.png');
                 $PhpQRCode->init();
             } else {
                 $insert = array();
                 $insert['goods_commonid'] = $common_id;
                 $insert['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']);
                 $insert['goods_jingle'] = $update_common['goods_jingle'];
                 $insert['store_id'] = $_SESSION['store_id'];
                 $insert['store_name'] = $_SESSION['store_name'];
                 $insert['gc_id'] = $update_common['gc_id'];
                 $insert['gc_id_1'] = $update_common['gc_id_1'];
                 $insert['gc_id_2'] = $update_common['gc_id_2'];
                 $insert['gc_id_3'] = $update_common['gc_id_3'];
                 $insert['brand_id'] = $update_common['brand_id'];
                 $insert['goods_price'] = $value['price'];
                 $insert['goods_promotion_price'] = $value['price'];
                 $insert['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice'];
                 $insert['goods_serial'] = $value['sku'];
                 $insert['goods_storage_alarm'] = intval($value['alarm']);
                 $insert['goods_spec'] = serialize($value['sp_value']);
                 $insert['goods_storage'] = $value['stock'];
                 $insert['goods_image'] = $update_common['goods_image'];
                 $insert['goods_state'] = $update_common['goods_state'];
                 $insert['goods_verify'] = $update_common['goods_verify'];
                 $insert['goods_addtime'] = TIMESTAMP;
                 $insert['goods_edittime'] = TIMESTAMP;
                 $insert['areaid_1'] = $update_common['areaid_1'];
                 $insert['areaid_2'] = $update_common['areaid_2'];
                 $insert['color_id'] = intval($value['color']);
                 $insert['transport_id'] = $update_common['transport_id'];
                 $insert['goods_freight'] = $update_common['goods_freight'];
                 $insert['goods_vat'] = $update_common['goods_vat'];
                 $insert['store_mentioning'] = $update_common['store_mentioning'];
                 $insert['goods_commend'] = $update_common['goods_commend'];
                 $insert['goods_stcids'] = $update_common['goods_stcids'];
                 $insert['is_virtual'] = $update_common['is_virtual'];
                 $insert['virtual_indate'] = $update_common['virtual_indate'];
                 $insert['virtual_limit'] = $update_common['virtual_limit'];
                 $insert['virtual_invalid_refund'] = $update_common['virtual_invalid_refund'];
                 $insert['is_fcode'] = $update_common['is_fcode'];
                 $insert['is_appoint'] = $update_common['is_appoint'];
                 $insert['is_presell'] = $update_common['is_presell'];
                 $insert['is_own_shop'] = $update_common['is_own_shop'];
                 $goods_id = $model_goods->addGoods($insert);
                 // 生成商品二维码
                 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id);
                 $PhpQRCode->set('pngTempName', $goods_id . '.png');
                 $PhpQRCode->init();
             }
             $goodsid_array[] = intval($goods_id);
             $colorid_array[] = intval($value['color']);
             $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr']));
         }
     } else {
         $goods_info = $model_goods->getGoodsInfo(array('goods_spec' => serialize(null), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id');
         if (!empty($goods_info)) {
             $goods_id = $goods_info['goods_id'];
             $update = array();
             $update['goods_commonid'] = $common_id;
             $update['goods_name'] = $update_common['goods_name'];
             $update['goods_jingle'] = $update_common['goods_jingle'];
             $update['store_id'] = $_SESSION['store_id'];
             $update['store_name'] = $_SESSION['store_name'];
             $update['gc_id'] = $update_common['gc_id'];
             $update['gc_id_1'] = $update_common['gc_id_1'];
             $update['gc_id_2'] = $update_common['gc_id_2'];
             $update['gc_id_3'] = $update_common['gc_id_3'];
             $update['brand_id'] = $update_common['brand_id'];
             $update['goods_price'] = $update_common['goods_price'];
             $update['goods_marketprice'] = $update_common['goods_marketprice'];
             $update['goods_serial'] = $update_common['goods_serial'];
             $update['goods_storage_alarm'] = $update_common['goods_storage_alarm'];
             $update['goods_spec'] = serialize(null);
             $update['goods_storage'] = intval($_POST['g_storage']);
             $update['goods_state'] = $update_common['goods_state'];
             $update['goods_verify'] = $update_common['goods_verify'];
             $update['goods_edittime'] = TIMESTAMP;
             $update['areaid_1'] = $update_common['areaid_1'];
             $update['areaid_2'] = $update_common['areaid_2'];
             $update['color_id'] = 0;
             $update['transport_id'] = $update_common['transport_id'];
             $update['goods_freight'] = $update_common['goods_freight'];
             $update['goods_vat'] = $update_common['goods_vat'];
             $update['goods_commend'] = $update_common['goods_commend'];
             $update['goods_stcids'] = $update_common['goods_stcids'];
             $update['is_virtual'] = $update_common['is_virtual'];
             $update['virtual_indate'] = $update_common['virtual_indate'];
             $update['virtual_limit'] = $update_common['virtual_limit'];
             $update['virtual_invalid_refund'] = $update_common['virtual_invalid_refund'];
             $update['is_fcode'] = $update_common['is_fcode'];
             $update['is_appoint'] = $update_common['is_appoint'];
             $update['is_presell'] = $update_common['is_presell'];
             $update['store_mentioning'] = $update_common['store_mentioning'];
             if ($update_common['is_virtual'] == 1) {
                 $update['have_gift'] = 0;
                 $model_gift->delGoodsGift(array('goods_id' => $goods_id));
             }
             $update['is_own_shop'] = $update_common['is_own_shop'];
             $model_goods->editGoodsById($update, $goods_id);
             // 生成商品二维码
             $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id);
             $PhpQRCode->set('pngTempName', $goods_id . '.png');
             $PhpQRCode->init();
         } else {
             $insert = array();
             $insert['goods_commonid'] = $common_id;
             $insert['goods_name'] = $update_common['goods_name'];
             $insert['goods_jingle'] = $update_common['goods_jingle'];
             $insert['store_id'] = $_SESSION['store_id'];
             $insert['store_name'] = $_SESSION['store_name'];
             $insert['gc_id'] = $update_common['gc_id'];
             $insert['gc_id_1'] = $update_common['gc_id_1'];
             $insert['gc_id_2'] = $update_common['gc_id_2'];
             $insert['gc_id_3'] = $update_common['gc_id_3'];
             $insert['brand_id'] = $update_common['brand_id'];
             $insert['goods_price'] = $update_common['goods_price'];
             $insert['goods_promotion_price'] = $update_common['goods_price'];
             $insert['goods_marketprice'] = $update_common['goods_marketprice'];
             $insert['goods_serial'] = $update_common['goods_serial'];
             $insert['goods_storage_alarm'] = $update_common['goods_storage_alarm'];
             $insert['goods_spec'] = serialize(null);
             $insert['goods_storage'] = intval($_POST['g_storage']);
             $insert['goods_image'] = $update_common['goods_image'];
             $insert['goods_state'] = $update_common['goods_state'];
             $insert['goods_verify'] = $update_common['goods_verify'];
             $insert['goods_addtime'] = TIMESTAMP;
             $insert['goods_edittime'] = TIMESTAMP;
             $insert['areaid_1'] = $update_common['areaid_1'];
             $insert['areaid_2'] = $update_common['areaid_2'];
             $insert['color_id'] = 0;
             $insert['transport_id'] = $update_common['transport_id'];
             $insert['goods_freight'] = $update_common['goods_freight'];
             $insert['goods_vat'] = $update_common['goods_vat'];
             $insert['goods_commend'] = $update_common['goods_commend'];
             $insert['goods_stcids'] = $update_common['goods_stcids'];
             $insert['is_virtual'] = $update_common['is_virtual'];
             $insert['virtual_indate'] = $update_common['virtual_indate'];
             $insert['virtual_limit'] = $update_common['virtual_limit'];
             $insert['virtual_invalid_refund'] = $update_common['virtual_invalid_refund'];
             $insert['is_fcode'] = $update_common['is_fcode'];
             $insert['is_appoint'] = $update_common['is_appoint'];
             $insert['is_presell'] = $update_common['is_presell'];
             $insert['is_own_shop'] = $update_common['is_own_shop'];
             $insert['store_mentioning'] = $update_common['store_mentioning'];
             $goods_id = $model_goods->addGoods($insert);
         }
         $goodsid_array[] = intval($goods_id);
         $colorid_array[] = 0;
         $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr']));
     }
     // 生成商品二维码
     if (!empty($goodsid_array)) {
         //Uk86QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array));
         // 生成商品二维码
         $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id);
         $PhpQRCode->set('pngTempName', $goods_id . '.png');
         $PhpQRCode->init();
     }
     // 清理商品数据
     $model_goods->delGoods(array('goods_id' => array('not in', $goodsid_array), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']));
     // 清理商品图片表
     $colorid_array = array_unique($colorid_array);
     $model_goods->delGoodsImages(array('goods_commonid' => $common_id, 'color_id' => array('not in', $colorid_array)));
     // 更新商品默认主图
     $default_image_list = $model_goods->getGoodsImageList(array('goods_commonid' => $common_id, 'is_default' => 1), 'color_id,goods_image');
     if (!empty($default_image_list)) {
         foreach ($default_image_list as $val) {
             $model_goods->editGoods(array('goods_image' => $val['goods_image']), array('goods_commonid' => $common_id, 'color_id' => $val['color_id']));
         }
     }
     // 商品加入上架队列
     if (isset($_POST['starttime'])) {
         $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60;
         if ($selltime > TIMESTAMP) {
             $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1), true);
         }
     }
     // 添加操作日志
     $this->recordSellerLog('编辑商品,平台货号:' . $common_id);
     if ($update_common['is_virtual'] == 1 || $update_common['is_fcode'] == 1 || $update_common['is_presell'] == 1) {
         // 如果是特殊商品清理促销活动,抢购、限时折扣、组合销售
         Uk86QueueClient::push('clearSpecialGoodsPromotion', array('goods_commonid' => $common_id, 'goodsid_array' => $goodsid_array));
     } else {
         // 更新商品促销价格
         Uk86QueueClient::push('updateGoodsPromotionPriceByGoodsCommonId', $common_id);
     }
     // 生成F码
     if ($update_common['is_fcode'] == 1) {
         Uk86QueueClient::push('createGoodsFCode', array('goods_commonid' => $common_id, 'fc_count' => intval($_POST['g_fccount']), 'fc_prefix' => $_POST['g_fcprefix']));
     }
     $return = $model_goods->editGoodsCommon($update_common, array('goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']));
     if ($return) {
         //提交事务
         Model()->commit();
         showDialog(L('nc_common_op_succ'), $_POST['ref_url'], 'succ');
     } else {
         //回滚事务
         Model()->rollback();
         showDialog(L('store_goods_index_goods_edit_fail'), uk86_urlShop('store_goods_online', 'index'));
     }
 }
Example #11
0
/**
 * 验证是否为平台店铺 并且绑定了全部商品类目
 *
 * @return boolean
 */
function uk86_checkPlatformStoreBindingAllGoodsClass()
{
    return uk86_checkPlatformStore() && $_SESSION['bind_all_gc'];
}
Example #12
0
 /**
  * 卖家店铺主题设置
  *
  * @param string
  * @param string
  * @return
  */
 public function themeOp()
 {
     /**
      * 店铺信息
      */
     $store_class = Model('store');
     $store_info = $store_class->getStoreInfoByID($_SESSION['store_id']);
     /**
      * 主题配置信息
      */
     $style_data = array();
     $style_configurl = BASE_ROOT_PATH . DS . DIR_SHOP . '/templates/' . TPL_SHOP_NAME . DS . 'store' . DS . 'style' . DS . "styleconfig.php";
     if (file_exists($style_configurl)) {
         include_once $style_configurl;
     }
     /**
      * 转码
      */
     if (strtoupper(CHARSET) == 'GBK') {
         $style_data = Uk86Language::uk86_getGBK($style_data);
     }
     /**
      * 当前店铺主题
      */
     $curr_store_theme = !empty($store_info['store_theme']) ? $store_info['store_theme'] : 'default';
     /**
      * 当前店铺预览图片
      */
     $curr_image = SHOP_TEMPLATES_URL . '/store/style/' . $curr_store_theme . '/images/preview.jpg';
     $curr_theme = array('curr_name' => $curr_store_theme, 'curr_truename' => $style_data[$curr_store_theme]['truename'], 'curr_image' => $curr_image);
     // 自营店全部可用
     if (uk86_checkPlatformStore()) {
         $themes = array_keys($style_data);
     } else {
         /**
          * 店铺等级
          */
         $grade_class = Model('store_grade');
         $grade = $grade_class->getOneGrade($store_info['grade_id']);
         /**
          * 可用主题
          */
         $themes = explode('|', $grade['sg_template']);
     }
     /**
      * 可用主题预览图片
      */
     foreach ($style_data as $key => $val) {
         if (in_array($key, $themes)) {
             $theme_list[$key] = array('name' => $key, 'truename' => $val['truename'], 'image' => SHOP_TEMPLATES_URL . '/store/style/' . $key . '/images/preview.jpg');
         }
     }
     /**
      * 页面输出
      */
     self::profile_menu('store_theme', 'store_theme');
     Tpl::output('store_info', $store_info);
     Tpl::output('curr_theme', $curr_theme);
     Tpl::output('theme_list', $theme_list);
     Tpl::showpage('store_theme');
 }
 /**
  * 套餐活动添加
  */
 public function bundling_addOp()
 {
     /**
      * 实例化模型
      */
     $model_bundling = Model('p_bundling');
     // 验证套餐数量
     if (intval(C('promotion_bundling_sum')) != 0 && !isset($_REQUEST['bundling_id'])) {
         $count = $model_bundling->getBundlingCount(array('store_id' => $_SESSION['store_id']));
         if (intval(C('promotion_bundling_sum')) <= intval($count)) {
             uk86_showMessage(L('bundling_add_fail_quantity_beyond'), '', '', 'error');
         }
     }
     if (uk86_chksubmit()) {
         // 插入套餐
         $data = array();
         if (isset($_POST['bundling_id'])) {
             $data['bl_id'] = intval($_POST['bundling_id']);
         }
         $data['bl_name'] = $_POST['bundling_name'];
         $data['store_id'] = $_SESSION['store_id'];
         $data['store_name'] = $_SESSION['store_name'];
         $data['bl_discount_price'] = $_POST['discount_price'];
         $data['bl_freight_choose'] = $_POST['bundling_freight_choose'];
         $data['bl_freight'] = $_POST['bundling_freight'];
         $data['bl_state'] = intval($_POST['state']);
         $return = $model_bundling->addBundling($data, true);
         if (!$return) {
             showDialog(L('nc_common_op_fail'), '', '', 'error');
         }
         // 插入套餐商品
         $model_goods = Model('goods');
         $data_goods = array();
         $appoint_goodsid = false;
         $model_bundling->delBundlingGoods(array('bl_id' => intval($_POST['bundling_id'])));
         if (!empty($_POST['goods']) && is_array($_POST['goods'])) {
             foreach ($_POST['goods'] as $key => $val) {
                 // 验证是否为本店铺商品
                 $goods_info = $model_goods->getGoodsInfoByID($val['gid'], 'goods_id,goods_name,goods_image,store_id');
                 if (empty($goods_info) || $goods_info['store_id'] != $_SESSION['store_id']) {
                     continue;
                 }
                 $data = array();
                 $data['bl_id'] = isset($_POST['bundling_id']) ? intval($_POST['bundling_id']) : $return;
                 $data['goods_id'] = $goods_info['goods_id'];
                 $data['goods_name'] = $goods_info['goods_name'];
                 $data['goods_image'] = $goods_info['goods_image'];
                 $data['bl_goods_price'] = uk86_ncPriceFormat($val['price']);
                 $data['bl_appoint'] = intval($val['appoint']);
                 if (!$appoint_goodsid && intval($val['appoint']) == 1) {
                     $appoint_goodsid = intval($val['gid']);
                 }
                 $data_goods[] = $data;
             }
         }
         // 插入数据
         $return = $model_bundling->addBundlingGoodsAll($data_goods);
         if (!isset($_POST['bundling_id']) && !$appoint_goodsid) {
             // 自动发布动态
             // bl_id,bl_name,image_path,bl_discount_price,bl_freight_choose,bl_freight,store_id
             $data_array = array();
             $data_array['bl_id'] = $return;
             $data_array['goods_id'] = $appoint_goodsid;
             $data_array['bl_name'] = $data['bl_name'];
             $data_array['bl_img'] = empty($_POST['image_path']) ? '' : $_POST['image_path'][0];
             $data_array['bl_discount_price'] = $data['bl_discount_price'];
             $data_array['bl_freight_choose'] = $data['bl_freight_choose'];
             $data_array['bl_freight'] = $data['bl_freight'];
             $data_array['store_id'] = $_SESSION['store_id'];
             $this->storeAutoShare($data_array, 'bundling');
         }
         $this->recordSellerLog('添加优惠套装,名称:' . $data['bl_name'] . ' id:' . $return);
         showDialog(L('nc_common_op_succ'), uk86_urlShop('store_promotion_bundling', 'bundling_list'), 'succ');
     }
     // 是否能使用编辑器
     if (uk86_checkPlatformStore()) {
         // 平台店铺可以使用编辑器
         $editor_multimedia = true;
     } else {
         // 三方店铺需要
         $editor_multimedia = false;
         if ($this->store_grade['sg_function'] == 'editor_multimedia') {
             $editor_multimedia = true;
         }
     }
     Tpl::output('editor_multimedia', $editor_multimedia);
     if (intval($_GET['bundling_id']) > 0) {
         $bundling_info = $model_bundling->getBundlingInfo(array('bl_id' => intval($_GET['bundling_id']), 'store_id' => $_SESSION['store_id']));
         Tpl::output('bundling_info', $bundling_info);
         // 验证是否属于自己的组合套餐
         if (empty($bundling_info['store_id'])) {
             uk86_showMessage(L('wrong_argument'), uk86_urlShop('store_promotion_bundling', 'bundling_list'), '', 'error');
         }
         $b_goods_list = $model_bundling->getBundlingGoodsList(array('bl_id' => intval($_GET['bundling_id'])));
         if (!empty($b_goods_list)) {
             $goodsid_array = array();
             foreach ($b_goods_list as $val) {
                 $goodsid_array[] = $val['goods_id'];
             }
             $goods_list = Model('goods')->getGoodsList(array('goods_id' => array('in', $goodsid_array)), 'goods_id,goods_price,goods_image,goods_name');
             Tpl::output('goods_list', uk86_array_under_reset($goods_list, 'goods_id'));
         }
         Tpl::output('b_goods_list', $b_goods_list);
         // 输出导航
         self::profile_menu('bundling_edit', 'bundling_edit');
     } else {
         // 输出导航
         self::profile_menu('bundling_add', 'bundling_add');
     }
     Tpl::showpage('store_promotion_bundling.add');
 }
Example #14
0
 public function templateeditOp()
 {
     $t_id = intval($_GET['tid']);
     if ($t_id <= 0) {
         $t_id = intval($_POST['tid']);
     }
     if ($t_id <= 0) {
         uk86_showMessage(Uk86Language::uk86_get('wrong_argument'), 'index.php?act=store_voucher&op=templatelist', 'html', 'error');
     }
     $model = Model('voucher');
     //查询模板信息
     $param = array();
     $param['voucher_t_id'] = $t_id;
     $param['voucher_t_store_id'] = $_SESSION['store_id'];
     $param['voucher_t_state'] = $this->templatestate_arr['usable'][0];
     $param['voucher_t_giveout'] = array('elt', '0');
     $param['voucher_t_end_date'] = array('gt', time());
     $t_info = $model->table('voucher_template')->where($param)->find();
     if (empty($t_info)) {
         uk86_showMessage(Uk86Language::uk86_get('wrong_argument'), 'index.php?act=store_voucher&op=templatelist', 'html', 'error');
     }
     if ($isOwnShop = uk86_checkPlatformStore()) {
         Tpl::output('isOwnShop', true);
     } else {
         //查询套餐信息
         $quotainfo = $model->table('voucher_quota')->where(array('quota_id' => $t_info['voucher_t_quotaid'], 'quota_storeid' => $_SESSION['store_id']))->find();
         if (empty($quotainfo)) {
             uk86_showMessage(Uk86Language::uk86_get('voucher_template_quotanull'), 'index.php?act=store_voucher&op=quotaadd', 'html', 'error');
         }
     }
     //查询面额列表
     $pricelist = $model->table('voucher_price')->order('voucher_price asc')->select();
     if (empty($pricelist)) {
         uk86_showMessage(Uk86Language::uk86_get('voucher_template_pricelisterror'), 'index.php?act=store_voucher&op=templatelist', 'html', 'error');
     }
     if (uk86_chksubmit()) {
         //验证提交的内容面额不能大于限额
         $obj_validate = new Uk86Validate();
         $obj_validate->validateparam = array(array("input" => $_POST['txt_template_title'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "50", "message" => Uk86Language::uk86_get('voucher_template_title_error')), array("input" => $_POST['txt_template_total'], "require" => "true", "validator" => "Number", "message" => Uk86Language::uk86_get('voucher_template_total_error')), array("input" => $_POST['select_template_price'], "require" => "true", "validator" => "Number", "message" => Uk86Language::uk86_get('voucher_template_price_error')), array("input" => $_POST['txt_template_limit'], "require" => "true", "validator" => "Double", "message" => Uk86Language::uk86_get('voucher_template_limit_error')), array("input" => $_POST['txt_template_describe'], "require" => "true", "validator" => "Length", "min" => "1", "max" => "255", "message" => Uk86Language::uk86_get('voucher_template_describe_error')));
         $error = $obj_validate->uk86_validate();
         //金额验证
         $price = intval($_POST['select_template_price']) > 0 ? intval($_POST['select_template_price']) : 0;
         foreach ($pricelist as $k => $v) {
             if ($v['voucher_price'] == $price) {
                 $chooseprice = $v;
                 //取得当前选择的面额记录
             }
         }
         if (empty($chooseprice)) {
             $error .= Uk86Language::uk86_get('voucher_template_pricelisterror');
         }
         $limit = intval($_POST['txt_template_limit']) > 0 ? intval($_POST['txt_template_limit']) : 0;
         if ($price >= $limit) {
             $error .= Uk86Language::uk86_get('voucher_template_price_error');
         }
         if ($error) {
             showDialog($error, 'reload', 'error');
         } else {
             $update_arr = array();
             $update_arr['voucher_t_title'] = trim($_POST['txt_template_title']);
             $update_arr['voucher_t_desc'] = trim($_POST['txt_template_describe']);
             if ($_POST['txt_template_enddate']) {
                 $enddate = strtotime($_POST['txt_template_enddate']);
                 if (!$isOwnShop && $enddate > $quotainfo['quota_endtime']) {
                     $enddate = $quotainfo['quota_endtime'];
                 }
                 $update_arr['voucher_t_end_date'] = $enddate;
             } else {
                 //如果没有添加有效期则默认为套餐的结束时间
                 if ($isOwnShop) {
                     $update_arr['voucher_t_end_date'] = time() + 2592000;
                 } else {
                     $update_arr['voucher_t_end_date'] = $quotainfo['quota_endtime'];
                 }
             }
             $update_arr['voucher_t_price'] = $price;
             $update_arr['voucher_t_limit'] = $limit;
             $update_arr['voucher_t_sc_id'] = intval($_POST['sc_id']);
             $update_arr['voucher_t_state'] = intval($_POST['tstate']) == $this->templatestate_arr['usable'][0] ? $this->templatestate_arr['usable'][0] : $this->templatestate_arr['disabled'][0];
             $update_arr['voucher_t_total'] = intval($_POST['txt_template_total']) > 0 ? intval($_POST['txt_template_total']) : 0;
             $update_arr['voucher_t_points'] = $chooseprice['voucher_defaultpoints'];
             $update_arr['voucher_t_eachlimit'] = intval($_POST['eachlimit']) > 0 ? intval($_POST['eachlimit']) : 0;
             //自定义图片
             if (!empty($_FILES['customimg']['name'])) {
                 $upload = new Uk86UploadFile();
                 $upload->uk86_set('default_dir', ATTACH_VOUCHER . DS . $_SESSION['store_id']);
                 $upload->uk86_set('thumb_width', '160');
                 $upload->uk86_set('thumb_height', '160');
                 $upload->uk86_set('thumb_ext', '_small');
                 $result = $upload->uk86_upfile('customimg');
                 if ($result) {
                     //删除原图
                     if (!empty($t_info['voucher_t_customimg'])) {
                         //如果模板存在,则删除原模板图片
                         @unlink(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . $t_info['voucher_t_customimg']);
                         @unlink(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . str_ireplace('.', '_small.', $t_info['voucher_t_customimg']));
                     }
                     $update_arr['voucher_t_customimg'] = $upload->file_name;
                 }
             }
             $rs = $model->table('voucher_template')->where(array('voucher_t_id' => $t_info['voucher_t_id']))->update($update_arr);
             if ($rs) {
                 showDialog(Uk86Language::uk86_get('nc_common_op_succ'), 'index.php?act=store_voucher&op=templatelist', 'succ');
             } else {
                 showDialog(Uk86Language::uk86_get('nc_common_op_fail'), 'index.php?act=store_voucher&op=templatelist', 'error');
             }
         }
     } else {
         if (!$t_info['voucher_t_customimg'] || !file_exists(BASE_UPLOAD_PATH . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . $t_info['voucher_t_customimg'])) {
             $t_info['voucher_t_customimg'] = UPLOAD_SITE_URL . DS . uk86_defaultGoodsImage(240);
         } else {
             $t_info['voucher_t_customimg'] = UPLOAD_SITE_URL . DS . ATTACH_VOUCHER . DS . $_SESSION['store_id'] . DS . str_ireplace('.', '_small.', $t_info['voucher_t_customimg']);
         }
         TPL::output('type', 'edit');
         TPL::output('t_info', $t_info);
         //店铺分类
         $store_class = uk86_rkcache('store_class', true);
         Tpl::output('store_class', $store_class);
         //查询店铺详情
         $store_info = Model('store')->getStoreInfoByID($_SESSION['store_id']);
         TPL::output('store_info', $store_info);
         TPL::output('quotainfo', $quotainfo);
         TPL::output('pricelist', $pricelist);
         $this->profile_menu('templateedit', 'templateedit');
         Tpl::showpage('store_voucher_template.add');
     }
 }
<?php

defined('InUk86') or exit('Access Invalid!');
?>

<div class="tabmenu">
  <?php 
include uk86_template('layout/submenu');
if ($notOwnShop == !uk86_checkPlatformStore()) {
    ?>
  <a href="javascript:void(0)" class="ncsc-btn ncsc-btn-green" nc_type="dialog" dialog_title="申请新的经营类目" dialog_id="my_goods_brand_apply" dialog_width="480" uri="index.php?act=store_info&op=bind_class_add">申请新的经营类目</a>
<?php 
}
?>
  </div>

<?php 
if (uk86_checkPlatformStoreBindingAllGoodsClass()) {
    ?>
<table class="ncsc-default-table">
  <tbody>
    <tr>
      <td colspan="20" class="norecord"><div class="warning-option"><span>店铺已绑定全部商品类目</span></div></td>
    </tr>
  </tbody>
</table>

<?php 
} else {
    ?>
 /**
  * 促销分析
  */
 public function generalOp()
 {
     $model = Model('stat');
     //统计的日期0点
     $stat_time = strtotime(date('Y-m-d', time())) - 86400;
     /*
      * 近30天
      */
     $stime = $stat_time - 86400 * 29;
     //30天前
     $etime = $stat_time + 86400 - 1;
     //昨天23:59
     $statnew_arr = array();
     //查询订单表下单量、下单金额、下单客户数
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_add_time'] = array('between', array($stime, $etime));
     $field = ' COUNT(*) as ordernum, SUM(order_amount) as orderamount, COUNT(DISTINCT buyer_id) as ordermembernum, AVG(order_amount) as avgorderamount ';
     $stat_order = $model->getoneByStatorder($where, $field);
     $statnew_arr['ordernum'] = ($t = $stat_order['ordernum']) ? $t : 0;
     $statnew_arr['orderamount'] = uk86_ncPriceFormat(($t = $stat_order['orderamount']) ? $t : 0);
     $statnew_arr['ordermembernum'] = ($t = $stat_order['ordermembernum']) > 0 ? $t : 0;
     $statnew_arr['avgorderamount'] = uk86_ncPriceFormat(($t = $stat_order['avgorderamount']) ? $t : 0);
     unset($stat_order);
     //下单高峰期
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_add_time'] = array('between', array($stime, $etime));
     $field = ' HOUR(FROM_UNIXTIME(order_add_time)) as hourval,COUNT(*) as ordernum ';
     $orderlist = $model->statByStatorder($where, $field, 0, 0, 'ordernum desc,hourval asc', 'hourval');
     foreach ((array) $orderlist as $k => $v) {
         if ($k < 2) {
             //取前两个订单量高的时间段
             if (!$statnew_arr['hothour']) {
                 $statnew_arr['hothour'] = $v['hourval'] . ":00~" . ($v['hourval'] + 1) . ":00";
             } else {
                 $statnew_arr['hothour'] .= "," . ($v['hourval'] . ":00~" . ($v['hourval'] + 1) . ":00");
             }
         }
     }
     unset($orderlist);
     //查询订单商品表下单商品数
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_add_time'] = array('between', array($stime, $etime));
     $field = ' SUM(goods_num) as ordergoodsnum, AVG(goods_pay_price/goods_num) as avggoodsprice ';
     $stat_ordergoods = $model->getoneByStatordergoods($where, $field);
     $statnew_arr['ordergoodsnum'] = ($t = $stat_ordergoods['ordergoodsnum']) ? $t : 0;
     $statnew_arr['avggoodsprice'] = uk86_ncPriceFormat(($t = $stat_ordergoods['avggoodsprice']) ? $t : 0);
     unset($stat_ordergoods);
     //商品总数、收藏量
     $goods_list = $model->statByGoods(array('store_id' => $_SESSION['store_id'], 'is_virtual' => 0), 'COUNT(*) as goodsnum, SUM(goods_collect) as gcollectnum');
     $statnew_arr['goodsnum'] = ($t = $goods_list[0]['goodsnum']) > 0 ? $t : 0;
     $statnew_arr['gcollectnum'] = ($t = $goods_list[0]['gcollectnum']) > 0 ? $t : 0;
     //店铺收藏量
     $store_list = $model->getoneByStore(array('store_id' => $_SESSION['store_id']), 'store_collect');
     $statnew_arr['store_collect'] = ($t = $store_list['store_collect']) > 0 ? $t : 0;
     /*
      * 销售走势
      */
     //构造横轴数据
     for ($i = $stime; $i < $etime; $i += 86400) {
         //当前数据的时间
         $timetext = date('n', $i) . '-' . date('j', $i);
         //统计图数据
         $stat_list[$timetext] = 0;
         //横轴
         $stat_arr['xAxis']['categories'][] = $timetext;
     }
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_add_time'] = array('between', array($stime, $etime));
     $field = ' order_add_time,SUM(order_amount) as orderamount,MONTH(FROM_UNIXTIME(order_add_time)) as monthval,DAY(FROM_UNIXTIME(order_add_time)) as dayval ';
     $stat_order = $model->statByStatorder($where, $field, 0, 0, '', 'monthval,dayval');
     if ($stat_order) {
         foreach ($stat_order as $k => $v) {
             $stat_list[$v['monthval'] . '-' . $v['dayval']] = floatval($v['orderamount']);
         }
     }
     $stat_arr['legend']['enabled'] = false;
     $stat_arr['series'][0]['name'] = '下单金额';
     $stat_arr['series'][0]['data'] = array_values($stat_list);
     //得到统计图数据
     $stat_arr['title'] = '最近30天销售走势';
     $stat_arr['yAxis'] = '下单金额';
     $stattoday_json = uk86_getStatData_LineLabels($stat_arr);
     unset($stat_arr);
     /*
      * 7日内商品销售TOP30
      */
     $stime = $stat_time - 86400 * 6;
     //7天前0点
     $etime = $stat_time + 86400 - 1;
     //今天24点
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_add_time'] = array('between', array($stime, $etime));
     $field = ' sum(goods_num) as ordergoodsnum, goods_id, goods_name ';
     $goodstop30_arr = $model->statByStatordergoods($where, $field, 0, 30, 'ordergoodsnum desc', 'goods_id');
     /**
      * 7日内同行热卖商品
      */
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['order_add_time'] = array('between', array($stime, $etime));
     $where['store_id'] = array('neq', $_SESSION['store_id']);
     if (!uk86_checkPlatformStore()) {
         //如果不是平台店铺,则查询店铺经营类目的同行数据
         //查询店铺经营类目
         $store_bindclass = Model('store_bind_class')->getStoreBindClassList(array('store_id' => $_SESSION['store_id']));
         $goodsclassid_arr = array();
         foreach ((array) $store_bindclass as $k => $v) {
             if (intval($v['class_3']) > 0) {
                 $goodsclassid_arr[3][] = intval($v['class_3']);
             } elseif (intval($v['class_2']) > 0) {
                 $goodsclassid_arr[2][] = intval($v['class_2']);
             } elseif (intval($v['class_1']) > 0) {
                 $goodsclassid_arr[1][] = intval($v['class_1']);
             }
         }
         //拼接商品分类条件
         if ($goodsclassid_arr) {
             ksort($goodsclassid_arr);
             $gc_parentidwhere_keyarr = array();
             $gc_parentidwhere_arr = array();
             foreach ((array) $goodsclassid_arr as $k => $v) {
                 $gc_parentidwhere_keyarr[] = 'gc_parentid_' . $k;
                 $gc_parentidwhere_arr[] = array('in', $goodsclassid_arr[$k]);
             }
             if (count($gc_parentidwhere_keyarr) == 1) {
                 $where[$gc_parentidwhere_keyarr[0]] = $gc_parentidwhere_arr[0];
             } else {
                 $gc_parentidwhere_arr['_multi'] = '1';
                 $where[implode('|', $gc_parentidwhere_keyarr)] = $gc_parentidwhere_arr;
             }
         }
     }
     $field = ' sum(goods_num) as ordergoodsnum, goods_id, goods_name ';
     $othergoodstop30_arr = $model->statByStatordergoods($where, $field, 0, 30, 'ordergoodsnum desc', 'goods_id');
     Tpl::output('goodstop30_arr', $goodstop30_arr);
     Tpl::output('othergoodstop30_arr', $othergoodstop30_arr);
     Tpl::output('stattoday_json', $stattoday_json);
     Tpl::output('statnew_arr', $statnew_arr);
     Tpl::output('stat_time', $stat_time);
     Tpl::showpage('stat.general.index');
 }
 /**
  * 选择商品
  */
 public function choosed_goodsOp()
 {
     $gid = $_GET['gid'];
     if ($gid <= 0) {
         $data = array('result' => 'false', 'msg' => '参数错误');
         $this->_echoJson($data);
     }
     // 验证商品是否存在
     $goods_info = Model('goods')->getGoodsInfoByID($gid, 'goods_id,goods_name,goods_image,goods_price,store_id,gc_id');
     if (empty($goods_info) || $goods_info['store_id'] != $_SESSION['store_id']) {
         $data = array('result' => 'false', 'msg' => '参数错误');
         $this->_echoJson($data);
     }
     $model_booth = Model('p_booth');
     if (!uk86_checkPlatformStore()) {
         // 验证套餐时候过期
         $booth_info = $model_booth->getBoothQuotaInfo(array('store_id' => $_SESSION['store_id'], 'booth_quota_endtime' => array('gt', TIMESTAMP)), 'booth_quota_id');
         if (empty($booth_info)) {
             $data = array('result' => 'false', 'msg' => '套餐过期请重新购买套餐');
             $this->_echoJson($data);
         }
     }
     // 验证已添加商品数量,及选择商品是否已经被添加过
     $bootgoods_info = $model_booth->getBoothGoodsList(array('store_id' => $_SESSION['store_id']), 'goods_id');
     // 已添加商品总数
     if (count($bootgoods_info) >= C('promotion_booth_goods_sum')) {
         $data = array('result' => 'false', 'msg' => '只能添加' . C('promotion_booth_goods_sum') . '个商品');
         $this->_echoJson($data);
     }
     // 商品是否已经被添加
     $bootgoods_info = uk86_array_under_reset($bootgoods_info, 'goods_id');
     if (isset($bootgoods_info[$gid])) {
         $data = array('result' => 'false', 'msg' => '商品已经添加,请选择其他商品');
         $this->_echoJson($data);
     }
     // 保存到推荐展位商品表
     $insert = array();
     $insert['store_id'] = $_SESSION['store_id'];
     $insert['goods_id'] = $goods_info['goods_id'];
     $insert['gc_id'] = $goods_info['gc_id'];
     $model_booth->addBoothGoods($insert);
     $this->recordSellerLog('添加推荐展位商品,商品id:' . $goods_info['goods_id']);
     // 输出商品信息
     $goods_info['goods_image'] = uk86_thumb($goods_info);
     $goods_info['url'] = uk86_urlShop('goods', 'index', array('goods_id' => $goods_info['goods_id']));
     $goods_class = Model('goods_class')->getGoodsClassInfoById($goods_info['gc_id']);
     $goods_info['gc_name'] = $goods_class['gc_name'];
     $goods_info['result'] = 'true';
     $this->_echoJson($goods_info);
 }