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 ...
随机推荐
- pip配置永久国内源
1.windows配置方式: (1)打开文件资源管理器 --------在地址栏中输入 %appdata% (2)手动创建一个文件夹叫做 pip (3)在pip的文件夹里面新建一个文件 pip.ini ...
- WinForm开发(6)——C#/winform程序打包部署时,如何把SQL数据库一起打包进去
打包数据库到安装程序中 方法1. 备份/恢复先备份数据库:backup database 数据库 to disk='c:\备份.bak' 将备份文件打包到安装程序中. 在第一次运行程序的时候,进行数据 ...
- 吴裕雄--天生自然Numpy库学习笔记:NumPy 切片和索引
ndarray 数组可以基于 0 - n 的下标进行索引,切片对象可以通过内置的 slice 函数,并设置 start, stop 及 step 参数进行,从原数组中切割出一个新数组. import ...
- Educational Codeforces Round 82 B. National Project
Your company was appointed to lay new asphalt on the highway of length nn. You know that every day y ...
- [蓝桥杯2017初赛]k倍区间 前缀和
题目描述 给定一个长度为N的数列,A1, A2, ... AN. 如果其中一段连续的子序列Ai, Ai+1, ... Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间. ...
- iOS 使用 Xcode8 制作动态库及静态库
在使用第三方 SDK 时,经常遇到他们提供的仅仅只有一个动态或静态库,并不能获取源码.使用动态库 FrameWork 或 静态库 Lib,可以满足不想把核心代码的具体实现向使用者展示,又能避免其他人错 ...
- Mybatis学习day2
Mybatis初探 之前已经用利用mybatis实现链接数据库查询所有用户的信息(用的是在resources下建立和Dao层一样目录的xml实现的).这次再来看一下增删改查等其它的操作. 利用Myba ...
- DOM的一些小总结
HTML DOM的结构:可以把HTML看成一个个的节点. 节点: HTML DOM对象 -- 方法和属性 一些DOM 对象方法 nodeName 属性 nodeValue 属性 nodeType:节 ...
- Python实现图片识别加翻译【高薪必学】
Python使用百度AI接口实现图片识别加翻译 另外很多人在学习Python的过程中,往往因为没有好的教程或者没人指导从而导致自己容易放弃,为此我建了个Python交流.裙 :一久武其而而流一思(数字 ...
- java 连接远程Linux 服务器
创建闭锁,确保能连接到zk服务器. // 创建闭锁final CountDownLatch countDownLatch = new CountDownLatch(1); String connect ...