陈伟 9 months ago
commit b6335af4bf
  1. 57
      app/admin/controller/Category.php
  2. 9
      app/admin/controller/Store.php
  3. 1
      app/api/controller/goods/Service.php
  4. 6
      app/api/model/Order.php
  5. 4
      app/api/service/order/Checkout.php
  6. 33
      app/common/model/Channel.php
  7. 12
      app/common/model/Goods.php

@ -14,6 +14,7 @@ namespace app\admin\controller;
use think\response\Json; use think\response\Json;
use app\store\model\Category as CategoryModel; use app\store\model\Category as CategoryModel;
use think\facade\Db;
/** /**
* 商品分类 * 商品分类
@ -85,4 +86,60 @@ class Category extends Controller
} }
return $this->renderError($model->getError() ?: '更新失败'); return $this->renderError($model->getError() ?: '更新失败');
} }
public function copyCategory(int $new_store_id){
$store_id = 0;
$model = new CategoryModel;
$list = $model->getList(['store_id' =>$store_id]);
if (!$list) {
return;
}
foreach ($list as $value) {
$value = $value->toArray();
$value['store_id'] = $new_store_id;
$value['create_time'] = time();
$value['update_time'] = time();
$temp = $value;
unset($temp['children']);
unset($temp['image']);
unset($temp['category_id']);
$firstid = Db::table('yoshop_category')->insertGetId($temp);
if (!isset($value['children']) || !$value['children']) {
continue;
}
foreach ($value['children'] as $value1) {
$value1 = $value1->toArray();
$value1['parent_id'] = $firstid;
$value1['store_id'] = $new_store_id;
$value1['create_time'] = time();
$value1['update_time'] = time();
$temp1 = $value1;
unset($temp1['children']);
unset($temp1['image']);
unset($temp1['category_id']);
$secondid = Db::table('yoshop_category')->insertGetId($temp1);
if (!isset($value1['children']) || !$value1['children']) {
continue;
}
foreach ($value1['children'] as $value2) {
$value2 = $value2->toArray();
$value2['parent_id'] = $secondid;
$value2['store_id'] = $new_store_id;
$value2['create_time'] = time();
$value2['update_time'] = time();
$temp2 = $value2;
unset($temp2['children']);
unset($temp2['image']);
unset($temp2['category_id']);
Db::table('yoshop_category')->insertGetId($temp2);
}
}
}
return $this->renderSuccess($list);
}
} }

@ -16,7 +16,7 @@ use think\response\Json;
use app\admin\model\Store as StoreModel; use app\admin\model\Store as StoreModel;
use app\admin\model\store\SyncTask; use app\admin\model\store\SyncTask;
use app\admin\service\store\User as StoreUserService; use app\admin\service\store\User as StoreUserService;
use app\common\model\Channel;
/** /**
* 商城管理 * 商城管理
* Class Store * Class Store
@ -162,7 +162,12 @@ class Store extends Controller
*/ */
public function platformList(): Json public function platformList(): Json
{ {
$platformList = config('app.platformList'); $list = Channel::where('status', 1)->select();
$platformList = [];
foreach ($list as $key => $value) {
$platformList[$value['code']] = $value['name'];
}
//$platformList = config('app.platformList');
return $this->renderSuccess($platformList); return $this->renderSuccess($platformList);
} }
/** /**

@ -34,6 +34,7 @@ class Service extends Controller
public function list(int $goodsId): Json public function list(int $goodsId): Json
{ {
$model = new ServiceModel; $model = new ServiceModel;
if(empty($goodsId)) return $this->renderError('goodsId非空');
$list = $model->getListByGoods($goodsId); $list = $model->getListByGoods($goodsId);
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }

@ -609,4 +609,10 @@ class Order extends OrderModel
'take_goods_number' => OrderModel::where('user_id', $userId)->where('delivery_type',20)->count(), // 发货记录&提货记录 'take_goods_number' => OrderModel::where('user_id', $userId)->where('delivery_type',20)->count(), // 发货记录&提货记录
]; ];
} }
public function getZitiAddressAttr($value) {
if(!empty($value)) return json_decode($value, true);
return $value;
}
} }

@ -853,9 +853,13 @@ class Checkout extends BaseService
'expect_receive_time' => $this->param['expect_receive_time'],//期待收货时间 'expect_receive_time' => $this->param['expect_receive_time'],//期待收货时间
'is_street_take' => $this->param['is_street_take'],//是否街边1-在 0-不在 'is_street_take' => $this->param['is_street_take'],//是否街边1-在 0-不在
'to_store_time' => $this->param['to_store_time'],//预计到店时间 'to_store_time' => $this->param['to_store_time'],//预计到店时间
'linkman' => $this->param['linkman'],
'phone' => $this->param['phone'],
'ziti_address' => !empty($this->param['ziti_address']) ? json_encode($this->param['ziti_address'], JSON_UNESCAPED_UNICODE) : '',
//添加成本价 //添加成本价
'cost_price' => $this->getCostPrice($order['goodsList']), 'cost_price' => $this->getCostPrice($order['goodsList']),
]; ];
// dd($data);
if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) { if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) {
$data['express_price'] = $order['expressPrice']; $data['express_price'] = $order['expressPrice'];
} elseif ($order['delivery'] == DeliveryTypeEnum::EXTRACT) { } elseif ($order['delivery'] == DeliveryTypeEnum::EXTRACT) {

@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasOne;
/**
* 文章模型
* Class Article
* @package app\common\model
*/
class Channel extends BaseModel
{
// 定义表名
protected $name = 'channel';
// 定义主键
protected $pk = 'id';
}

@ -25,7 +25,7 @@ use think\model\relation\BelongsTo;
use think\model\relation\HasMany; use think\model\relation\HasMany;
use think\model\relation\HasOne; use think\model\relation\HasOne;
use think\Paginator; use think\Paginator;
use app\common\model\Channel;
/** /**
* 商品模型 * 商品模型
* Class Goods * Class Goods
@ -78,7 +78,7 @@ class Goods extends BaseModel
*/ */
public function getContentAttr($value): string public function getContentAttr($value): string
{ {
return htmlspecialchars_decode($value); return $value ? htmlspecialchars_decode($value) : "";
} }
/** /**
@ -343,8 +343,10 @@ class Goods extends BaseModel
if ($list->isEmpty()) { if ($list->isEmpty()) {
return $list; return $list;
} }
// 遍历商品列表整理数据 // 遍历商品列表整理数据
foreach ($list as &$goods) { foreach ($list as &$goods) {
$goods = $this->setGoodsData($goods, $callback); $goods = $this->setGoodsData($goods, $callback);
} }
@ -359,10 +361,12 @@ class Goods extends BaseModel
*/ */
protected function setGoodsData($goodsInfo, callable $callback = null) protected function setGoodsData($goodsInfo, callable $callback = null)
{ {
// 商品图片列表 $channel = Channel::where('code', $goodsInfo['channel'])->find();
$goodsInfo['channel_name'] = $channel['name'] ?? "";
$goodsInfo['goods_images'] = helper::getArrayColumn($goodsInfo['images'], 'file'); $goodsInfo['goods_images'] = helper::getArrayColumn($goodsInfo['images'], 'file');
// 商品主图 // 商品主图
$goodsInfo['goods_image'] = current($goodsInfo['goods_images'])['preview_url']; $goodsInfo['goods_image'] = $goodsInfo['goods_images'] ? current($goodsInfo['goods_images'])['preview_url'] : "";
// 商品销量(实际显示=初始虚拟销量+实际销量) // 商品销量(实际显示=初始虚拟销量+实际销量)
$goodsInfo['goods_sales'] = $goodsInfo['sales_initial'] + $goodsInfo['sales_actual']; $goodsInfo['goods_sales'] = $goodsInfo['sales_initial'] + $goodsInfo['sales_actual'];
// //商品价格判断 // //商品价格判断

Loading…
Cancel
Save