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 ...
随机推荐
- ZOJ007 Numerical Summation of a Series(纯数学)
#include<bits/stdc++.h> using namespace std; int main() { double i; double k; for(i=0.000;i-2. ...
- Codeforce 977E Cyclic Components
dfs判断图的连通块数量~ #include<cstdio> #include<algorithm> #include<vector> #include<cs ...
- Cisco TrustSec(理解)
1.Cisco TrustSec的限制当指定了无效的设备ID时,受保护的访问凭据(Protected access credential,PAC)设置将失败并保持挂起状态. 即使在清除PAC并配置正确 ...
- Python中的代码块及其缓存机制、深浅copy
一.代码块及其缓存机制 代码块 一个模块.一个函数.一个类.一个文件等都是一个代码块:交互式命令下,一行就是一个代码块. 同一个代码块内的缓存机制(字符串驻留机制) 机制内容:Python在执行同一个 ...
- linux和windows系统的区别
在21世纪的今天,互联网可以说是当代发展最为迅速的行业,举个很简单的例子,现在的我们不论什么年龄阶层,几乎人手都有一部手机,上面的某博,某音,末手等软件,更是受到多数人的热爱,并且人们不仅仅用其来消遣 ...
- ypACM社团年终赛暨实验室选拔赛题解
记得补题,题目两小时半还是挺困难ak的,毕竟我验题也验了几天的时间,题目基本没有锅.题目基本属于简单题 我的三道题都是很基本的题目,希望大家补题 这些题解都是我写的,如果有疑问可以qq问我 所有的核心 ...
- SpringBoot实现restuful风格的CRUD
restuful风格: 百度百科: RESTFUL是一种网络应用程序的设计风格和开发方式,基于HTTP,可以使用XML格式定义或JSON格式定义.RESTFUL适用于移动互联网厂商作为业务使能接口的场 ...
- springBoot+MybatisPlus数据库字段使用驼峰命名法时报错
假如有个实体类: package com.jeff.entity; public class User { /** * 主键id */ private Integer id; /** * 登陆名 */ ...
- async处理异步操作
async函数用async作为关键字,try和 catch来处理异常, await接受一个promise函数返回 async list () { try { await api.findjuBarDa ...
- 面试官:说说Spring中的事务传播行为
前言 在开发中,相信大家都使用过Spring的事务管理功能.那么,你是否有了解过,Spring的事务传播行为呢? Spring中,有7种类型的事务传播行为.事务传播行为是Spring框架提供的一种事务 ...