diff --git a/app/admin/controller/Category.php b/app/admin/controller/Category.php index f652e730..fa618740 100644 --- a/app/admin/controller/Category.php +++ b/app/admin/controller/Category.php @@ -14,6 +14,7 @@ namespace app\admin\controller; use think\response\Json; use app\store\model\Category as CategoryModel; +use think\facade\Db; /** * 商品分类 @@ -85,4 +86,60 @@ class Category extends Controller } 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); + } + + } diff --git a/app/admin/controller/Store.php b/app/admin/controller/Store.php index 735df4e1..4c8bc1c9 100644 --- a/app/admin/controller/Store.php +++ b/app/admin/controller/Store.php @@ -16,7 +16,7 @@ use think\response\Json; use app\admin\model\Store as StoreModel; use app\admin\model\store\SyncTask; use app\admin\service\store\User as StoreUserService; - +use app\common\model\Channel; /** * 商城管理 * Class Store @@ -162,7 +162,12 @@ class Store extends Controller */ 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); } /** diff --git a/app/api/controller/goods/Service.php b/app/api/controller/goods/Service.php index b37e97f6..149e274d 100644 --- a/app/api/controller/goods/Service.php +++ b/app/api/controller/goods/Service.php @@ -34,6 +34,7 @@ class Service extends Controller public function list(int $goodsId): Json { $model = new ServiceModel; + if(empty($goodsId)) return $this->renderError('goodsId非空'); $list = $model->getListByGoods($goodsId); return $this->renderSuccess(compact('list')); } diff --git a/app/api/model/Order.php b/app/api/model/Order.php index 1070fb85..2a52f80e 100644 --- a/app/api/model/Order.php +++ b/app/api/model/Order.php @@ -609,4 +609,10 @@ class Order extends OrderModel '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; + } } diff --git a/app/api/service/order/Checkout.php b/app/api/service/order/Checkout.php index 5746aff4..20fd6235 100644 --- a/app/api/service/order/Checkout.php +++ b/app/api/service/order/Checkout.php @@ -853,9 +853,13 @@ class Checkout extends BaseService 'expect_receive_time' => $this->param['expect_receive_time'],//期待收货时间 'is_street_take' => $this->param['is_street_take'],//是否街边1-在 0-不在 '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']), ]; +// dd($data); if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) { $data['express_price'] = $order['expressPrice']; } elseif ($order['delivery'] == DeliveryTypeEnum::EXTRACT) { diff --git a/app/common/model/Channel.php b/app/common/model/Channel.php new file mode 100644 index 00000000..1843eecb --- /dev/null +++ b/app/common/model/Channel.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- +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'; + + +} diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 148503ad..2b686207 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -25,7 +25,7 @@ use think\model\relation\BelongsTo; use think\model\relation\HasMany; use think\model\relation\HasOne; use think\Paginator; - +use app\common\model\Channel; /** * 商品模型 * Class Goods @@ -78,7 +78,7 @@ class Goods extends BaseModel */ 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()) { return $list; } + // 遍历商品列表整理数据 foreach ($list as &$goods) { + $goods = $this->setGoodsData($goods, $callback); } @@ -359,10 +361,12 @@ class Goods extends BaseModel */ 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_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']; // //商品价格判断