完善商城快讯

This commit is contained in:
wangxiaowei 2024-07-23 23:33:26 +08:00
parent 5b575d2eca
commit 67f5104046
3 changed files with 74 additions and 54 deletions

@ -101,18 +101,18 @@ class Goods extends Api
$set = Procurementset::where("u_id",$p_id)->where("set_state",1)->order("set_update desc")->limit(1)->find();
}
$set_price_type = 0;
if ($set != null&&$settpye!=1) {
if($set['price_type']==1){
$set_price_type = 1;
}
if($set['price_type']==2){
$set_price_type = 2;
}
if($set['price_type']==3){
$set_price_type = 3;
}
if ($set != null&&$settpye!=1) {
if($set['price_type']==1){
$set_price_type = 1;
}
if($set['price_type']==2){
$set_price_type = 2;
}
if($set['price_type']==3){
$set_price_type = 3;
}
if ($set['set_pro'] != 0) {
// $set_price_type = 1;
// $set_price_type = 1;
if ($set['set_pro_type'] == 1) {
$goodsDetail['purchase_price'] = round($goodsDetail['purchase_price'] * (100 + $set['set_pro']) / 100, 2);
}
@ -121,7 +121,7 @@ class Goods extends Api
}
}
if ($set['set_issued'] != 0) {
// $set_price_type = 2;
// $set_price_type = 2;
if ($set['set_issued_type'] == 1) {
$goodsDetail['issuing_price'] = round($goodsDetail['issuing_price'] * (100 + $set['set_issued']) / 100, 2);
}
@ -130,7 +130,7 @@ class Goods extends Api
}
}
if ($set['set_wholesale'] != 0) {
// $set_price_type = 3;
// $set_price_type = 3;
if ($set['set_wholesale_type'] == 1) {
$goodsDetail['wholesale_price'] = round($goodsDetail['wholesale_price'] * (100 + $set['set_wholesale']) / 100, 2);
}
@ -185,7 +185,7 @@ class Goods extends Api
}
}
}
$goodsDetail['set_price_type'] = $set_price_type;
$goodsDetail['set_price_type'] = $set_price_type;
$rst = Mprocurement::where("user_id",$this->user_id)->where("u_state",1)->where("u_examine_state",1)->where("wholesale_state",2)->find();
if($rst==null){
// foreach($goodsDetail['goods_item'] as $k => $v){
@ -214,6 +214,7 @@ class Goods extends Api
return JsonServer::error('请求方式错误');
}
}
// 备用接口调整集采规格
public function getPurchasesku(){
$post = $this->request->post();
$purchase_sku= Goodspurchase::where('item_id', $post['id'])->select();
@ -288,44 +289,4 @@ class Goods extends Api
return JsonServer::error('请求方式错误');
}
}
public function pdTypeList(){
$result = GoodsLogic::getGoodsTypeList();
$data = $this -> list_to_tree($result,'id','pid');
if(!empty($result)){
return JsonServer::success('获取成功', $data);
}else{
return JsonServer::error('暂无数据');
}
}
//无限级栏目
function list_to_tree($list, $pk='type_id',$pid = 'type_parents',$child = 'msg_sub_menu',$root=0) {
// 创建Tree
$tree = array();
if(is_array($list)) {
// 创建基于主键的数组引用
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] =& $list[$key];
}
//循环所有的结果集
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
//如果ID是0,那么就是根目录
if ($root == $parentId) {
$list[$key][$child] = array();
$tree[] =& $list[$key];
}else{
if (isset($refer[$parentId])) {
$parent =& $refer[$parentId];
$parent[$child][] =& $list[$key];
}
}
}
}
return $tree;
}
}

@ -0,0 +1,22 @@
<?php
namespace app\api\controller;
use app\common\basics\Api;
use app\api\logic\MallNewsLogic;
use app\common\server\JsonServer;
class MallNews extends Api
{
public function list()
{
if($this->request->isGet()) {
$page = $this->request->get('page_no', $this->page_no);
$size = $this->request->get('page_size', $this->page_size);
$data = MallNewsLogic::lists($page, $size);
return JsonServer::success('获取成功', $data);
}else{
return JsonServer::error('请求方式错误');
}
}
}

@ -0,0 +1,37 @@
<?php
namespace app\api\logic;
use app\common\basics\Logic;
use think\facade\Db;
class MallNewsLogic extends Logic
{
public static function lists($page, $size)
{
$top = Db::name('mall_news')->where(['is_top' => 1, 'delete_time' => 0])->field('title, desc')->select();
$list = Db::name('mall_news')
->where(['is_top' => 0, 'delete_time' => 0])
->field('title, desc')
->order('sort desc, create_time desc')
->page($page,$size)
->select();
$count = Db::name('mall_news')
->where(['is_top' => 0, 'delete_time' => 0])
->field('title, desc')
->count();
$more = is_more($count, $page, $size); //是否有下一页
return [
'list' => $list,
'page_no' => $page,
'page_size' => $size,
'count' => $count,
'more' => $more,
'top' => $top,
];
}
}