php 实现店铺装修3
/**
* @title 装修店铺
* @param plate_id 是 int 店铺装修样式ID
* @param type 是 int 模板样式子板块类型(4-海景、6-二宫格、8-三宫格、9-四宫格)
* @param sort 是 int 模块排序位置
* @param sku_id 是 string 商品sku_id
* @param index 是 int 商品sku排序位置
* @param operate_type 是 int 1-替换商品、2-删除商品
* @param type_id 否 int 装修商品的类型(1-平台商品、2-特色商品)
* @example FlagShipShopDecorate.decorateShop? 调试参数:{"operate_type":"1","username":"17721355485","check_code":"123456","method":"FlagShipShopDecorate.decorateShop","plate_id":1,"type":8,"sort":"3","sku_id": "8032717999","index":"1","type_id":"1"}
* @return {"status":"0","errorCode":"0","msg":"成功","result":true}
* @method POST
* @author 邹柯
*/
public function decorateShop($res){
$user_id=session("user.user_id");
$plate_id=$res['plate_id'];
if(empty($plate_id)){
E('');
}
$type=$res['type'];
if($type != && $type != && $type != && $type !=){
E('');
}
$type_id=$res['type_id'];
if($type_id != && $type_id !=){
E('');
}
$sort=$res['sort'];
if(!is_numeric($sort) || $sort <= ){
E('');
}
$sku_id=$res['sku_id'];
if(empty($sku_id)){
E('');
}
$index=$res['index'];
if(!is_numeric($index) || $index <= ){
E('');
}
$operate_type=$res['operate_type'];
if($operate_type != && $operate_type !=){
E('');
}
$user_shop_decorate=M('user_shop_decorate');
$where['flagship_shop']=;
$where['create_id']=$user_id;
$usd_info=$user_shop_decorate->field('id,plate_id,plate_content_draft,plate_content_draft_features,select_status')->where($where)->order('create_time desc')->find();
if($type_id==){
if(empty($usd_info['plate_content_draft'])){
$plate_content_draft=$this->getDefaultStyleByPlateId($plate_id,$type_id);
}else{
$plate_content_draft=json_decode($usd_info['plate_content_draft'],true);
}
}else{
if(empty($usd_info['plate_content_draft_features'])){
$plate_content_draft=$this->getDefaultStyleByPlateId($plate_id,$type_id);
}else{
$plate_content_draft=json_decode($usd_info['plate_content_draft_features'],true);
}
} foreach($plate_content_draft as $k=>$v){
if($v['type']==$type && $v['sort']==$sort){
foreach($v['goods'] as $k2=>$v2){
if($v2['index']==$index){
$plate_content_draft[$k]['goods'][$k2]['sku_id']=$sku_id;
$plate_content_draft[$k]['goods'][$k2]['operate_type']=$operate_type;
}
}
}
}
$plate_content_draft_arr=json_encode($plate_content_draft);
$time=date("Y-m-d H:i:s",time());
if(!empty($usd_info)){ //修改
$u_where['id']=$usd_info['id'];
if($type_id==){
$data=array(
'plate_id' => $plate_id,
'plate_content_draft'=>$plate_content_draft_arr,
'status'=>,
'update_time'=>$time,
'update_id'=>$user_id,
'select_status'=>,
);
}else{
$data=array(
'plate_id_features' => $plate_id,
'plate_content_draft_features'=>$plate_content_draft_arr,
'status'=>,
'update_time'=>$time,
'update_id'=>$user_id,
'select_status'=>,
);
}
$res=$user_shop_decorate->data($data)->where($u_where)->save();
if(!$res && $res !=){
E('');
}
}else{ //添加
if($type_id==) {
$data = array(
'plate_id' => $plate_id,
'plate_content_draft' => $plate_content_draft_arr,
'status' => ,
'create_time' => $time,
'create_id' => $user_id,
'update_time' => $time,
'update_id' => $user_id,
'use_status' => ,
'select_status' =>
);
}else{
$data = array(
'plate_id_features' => $plate_id,
'plate_content_draft_features' => $plate_content_draft_arr,
'status' => ,
'create_time' => $time,
'create_id' => $user_id,
'update_time' => $time,
'update_id' => $user_id,
'use_status' => ,
'select_status' =>
);
}
$res=$user_shop_decorate->data($data)->add();
if(!$res){
E('');
}
}
$usd_where['plate_id']=array("neq",$plate_id);
$usd_where['create_id']=$user_id;
$res_info=$user_shop_decorate->data(['select_status'=>])->where($usd_where)->save();
if(!$res_info && $res_info !=){
E('');
}
return true;
}
//根据指定样式id获取样式下的默认商品信息
public function getDefaultStyleByPlateId($plate_id,$type_id){
$shop_decorate_template=M('shop_decorate_template');
$sd_where['id']=$plate_id;
$sd_where['is_deleted']=;
$sdt_info=$shop_decorate_template->field('id,plate_content,goods_nums')->where($sd_where)->find();
$plate_content=json_decode($sdt_info['plate_content'],true);
if($type_id==){
$goods_info=$this->getDefaultGoodsInfo($sdt_info['goods_nums'],"sell_nums desc",null,null,null,null,null,null,null,true,$plate_id);
foreach($goods_info as $k=>$v){
unset($goods_info[$k]['activity_info']);
unset($goods_info[$k]['store_id']);
unset($goods_info[$k]['sell_nums']);
unset($goods_info[$k]['sell_price']);
unset($goods_info[$k]['img']);
unset($goods_info[$k]['title']);
unset($goods_info[$k]['sku_no']);
unset($goods_info[$k]['short_name']);
unset($goods_info[$k]['search_name']);
unset($goods_info[$k]['product_id']);
unset($goods_info[$k]['imgs']);
unset($goods_info[$k]['seascapes']);
$goods_info[$k]['index']=$k+;
}
$total_nums=;
foreach($plate_content as $k=>$v){
$at=array_slice($goods_info,$total_nums,$v['goods_nums']);
$plate_content[$k]['goods']=$at;
$total_nums +=$v['goods_nums'];
unset($plate_content[$k]['goods_nums']);
}
}else{
$goods_info=$this->getDefaultGoodsNull($sdt_info['goods_nums'],$type_id);
$total_nums=;
foreach($plate_content as $k=>$v){
$at=array_slice($goods_info,$total_nums,$v['goods_nums']);
$plate_content[$k]['goods']=$at;
$total_nums +=$v['goods_nums'];
}
} return $plate_content;
} //获取默认空商品
public function getDefaultGoodsNull($goods_nums,$type_id){
$user_id=session("user.user_id");
$store=M('store');
$s_where['user_id']=$user_id;
$store_id=$store->where($s_where)->getField('id');
$store_goods=M('store_goods');
$gs_where['is_deleted']=;
$gs_where['is_open']=;
if($type_id==){
$gs_where['pt_cats']="0/1";
}else{
$gs_where['store_id']=$store_id;
}
$gs_info=$store_goods->where($gs_where)->field('sku_id')->find();
for($i=;$i<$goods_nums;$i++){
$goods[]=[
'sku_id'=>$gs_info['sku_id'],
'operate_type'=>,
'index'=>$i+
];
}
return $goods;
}
php 实现店铺装修3的更多相关文章
- 关于淘宝店铺装修弹出层popup的记录
小龙最近做了一下下淘宝的店铺装修,里面封装的widget深不见底,刚刚整明白popup,也就是弹出层的使用方法,大神勿喷: <div class="area001">触 ...
- Adobe Photoshop CC2018最新教程+某宝店铺装修教程
PS免费教程,ps淘宝店铺装修教程.该资源为本人从某商网站重金买来,现免费分享给大家,下载地址:百度网盘,https://pan.baidu.com/s/127PjFbGwVVUVce1litHFsw
- php 实现店铺装修5
/** * @title 选中蜂店装修模板样式 * @param plate_id 是 int 商品(平台或特色)装修样式ID * @param type_id 是 int 要装修商品的类型(1-平台 ...
- php 实现店铺装修6
/** * @title 获取预览或发布的蜂店模板样式 * @param store_id 是 string 店铺id * @param type 是 int 装修模板的状态:1-预览蜂店装修模板样式 ...
- php 实现店铺装修7
type_id=0的情况 type_id=1的情况 type_id=2的情况 /** * @title 店铺装修--商品分类 * @param type ...
- php 实现店铺装修8
/** * @title 店铺装修--根据分类获取商品列表 * @param source 是 int 来源(1--h5.2--app) * @param type 是 string 店铺类型--首页 ...
- php 实现店铺装修2
<?php namespace Webapp\Model; use Common\Model\DataModel\FlagShopCategoryModel; use Common\Model\ ...
- php 实现店铺装修1
一.原型分析 1.店铺未装修的情况下,使用默认样式,哪个是默认样式由后台告知: 2.所有的样式由后台进行维护(但后台始终有一个默认样式,不可删除不可编辑),所有样式,只要用户未编辑过,则默认按照商品的 ...
- php 实现店铺装修4
/** * @title 发布装修的店铺 * @example FlagShipShopDecorate.fabu? 调试参数:{"username":"17721355 ...
随机推荐
- Redis注意点记录
场景:1主2从 1.不使用哨兵模式,则当主机宕机后,从机并不会自动切换到Master状态,仍旧是Slave,若主机重新恢复,则从机进行自动连接 2.使用哨兵模式后,主机宕机,从机会根据分配的权值在从机 ...
- Spring学习(八)
AOP的重要概念 1.切面 : 切点(Pointcut) + Advice[ 在哪里 .加什么 ] 2.Advice: 在 切点 选中的 连接点 "加入" 的 代码 就是 Advi ...
- mDNS故障排查(译)
WLC上mDNS网关的理解及排查 第一部分:介绍 这篇文档描述了Bonjour协议在WLC上的操作,该文档旨在协助工程师理解该工作流量的原理以及提供故障排查的指导. 第二部分:需求和前提 知识需求: ...
- ES-elasticsearch安装-linux
(1)安装JDK(ES是使用java开发的) (2)安装ES(虚拟机内存大于一个g) 1)创建普通用户启动 2)非常占用内存(默认1个g的内存) (3)创建一个普通用户(用于启动ES) groupad ...
- java代码开启关闭线程(nginx)
源码: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; pub ...
- 基于springboot通过注解AOP动态切换druid多数据源--mybatis
控制于接口之上: 开始:demo地址 在lsr-core-base中 自定义注解: /** * @Description: 数据源切换注解 * @Package: lsr-microservice ...
- Codeforces Round #589 (Div. 2)E(组合数,容斥原理,更高复杂度做法为DP)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int f[257],fac[257],ifa ...
- Educational Codeforces Round 73 (Rated for Div. 2)F(线段树,扫描线)
这道题里线段树用来区间更新(每次给更大的区间加上当前区间的权重),用log的复杂度加快了更新速度,也用了区间查询(查询当前区间向右直至最右中以当前区间端点向右一段区间的和中最大的那一段的和),也用lo ...
- 如何删除 AppStore 中的恶意评论 iOS
AppStore 中的评论,对于产品的形象影响很大.如果评论榜中出现了恶意评论,会对产品形象影响很大,当然这些差评有可能是用户的真实反馈,需要产品设计人员做好产品设计,满足客户的需求.另外也可能是竞争 ...
- Linux中常用命令的使用(一)
这次只讲常用命令 先说命令的组成:命令一般由 (选项.命令.参数) 组成 下面就从开启一个Ubuntu开始说起 1.用户登录:在putty环境下,输完用户名在输入密码 别人想知道你用的linux系统 ...