lqmac 7 months ago
parent 1e7fae2ccd
commit 0fc84ef58c
  1. 3
      app/admin/controller/Goods.php
  2. 21
      app/admin/model/Store.php
  3. 3
      app/api/controller/Goods.php
  4. 2
      app/api/service/Cart.php
  5. 303
      app/command/SyncCategory.php
  6. 2
      app/common/model/Goods.php
  7. 22
      app/common/model/user/IdentityOrder.php
  8. 20
      app/store/controller/Order.php
  9. 2
      app/store/controller/Presale.php
  10. 16
      app/store/controller/user/Identity.php
  11. 69
      app/store/model/user/IdentityOrder.php
  12. 1
      config/console.php

@ -322,7 +322,8 @@ class Goods extends Controller
return $this->renderSuccess('删除成功');
}
public function export(){
ini_set('memory_limit', '2024M');
set_time_limit(0);
$model = new GoodsModel;
$params = $this->request->param();
$params['store_id'] = 0;

@ -114,6 +114,11 @@ class Store extends StoreModel
}
foreach ($list as $value) {
$value = $value->toArray();
if ($value['status'] != 1) {
continue;
}
$value['store_id'] = $new_store_id;
$value['create_time'] = time();
$value['update_time'] = time();
@ -134,6 +139,10 @@ class Store extends StoreModel
}
foreach ($value['children'] as $value1) {
$value1 = $value1->toArray();
if ($value1['status'] != 1) {
continue;
}
$value1['parent_id'] = $firstid;
$value1['store_id'] = $new_store_id;
$value1['create_time'] = time();
@ -153,6 +162,10 @@ class Store extends StoreModel
}
foreach ($value1['children'] as $value2) {
$value2 = $value2->toArray();
if ($value2['status'] != 1) {
continue;
}
$value2['parent_id'] = $secondid;
$value2['store_id'] = $new_store_id;
$value2['create_time'] = time();
@ -172,6 +185,10 @@ class Store extends StoreModel
}
foreach ($value2['children'] as $value3) {
$value3 = $value3->toArray();
if ($value3['status'] != 1) {
continue;
}
$value3['parent_id'] = $thirdid;
$value3['store_id'] = $new_store_id;
$value3['create_time'] = time();
@ -191,6 +208,10 @@ class Store extends StoreModel
}
foreach ($value3['children'] as $value4) {
$value4 = $value4->toArray();
if ($value4['status'] != 1) {
continue;
}
$value4['parent_id'] = $fourthid;
$value4['store_id'] = $new_store_id;
$value4['create_time'] = time();

@ -420,6 +420,9 @@ class Goods extends Controller
if (empty($page_url)) {
return $this->renderError('缺少参数page_url');
}
$page_url = urldecode($page_url);
log_record("page_url".urldecode($page_url));
//$page_url = "pages/goods/detail?refereeId=10472&goodsId=985456";
$page_title = $this->request->post('page_title');
if (empty($page_title)) {
return $this->renderError('缺少参数page_title');

@ -52,7 +52,7 @@ class Cart extends BaseService
$result = $this->findGoods($goodsList, $item, $enableGradeMoney);
//商户信息处理
if ($result['merchant_id'] && !in_array($result['channel'], config('app.not_show_merchant'))) {
$merchant = \app\common\model\Merchant::detail($result['merchant_id'], $result->store_id);
$merchant = \app\common\model\Merchant::detail($result['merchant_id'], $result['store_id']);
$result['merchant'] = $merchant;
} else {
$result['merchant_id'] = 0;

@ -0,0 +1,303 @@
<?php
namespace app\command;
use app\common\service\GoodsCateEs;
use app\common\service\GoodsEs;
use think\console\Command;
use think\console\Output;
use think\console\Input;
use app\store\model\Category as CategoryModel;
use app\common\model\Store;
use think\facade\Db;
class SyncCategory extends Command
{
const DEFAULT_STORE_ID = 0;
protected function configure()
{
// 指令配置
$this->setName('SyncCategory')->setDescription('同步商品数据到ES');
$this->addArgument("store_id");
$this->addArgument("is_update_image");
}
protected function execute(Input $input, Output $output)
{
$store_id = $input->getArgument("store_id");
$is_update_image = $input->getArgument("is_update_image");
$where[] = ['is_sync_cate','=', 1];
$where[] = ['is_delete','=', 0];
$where[] = ['is_recycle','=', 0];
$where[] = ['status','=', 1];
if ($store_id) {
$where[] = ['store_id','=', $store_id];
} else {
$where[] = ['store_id', '<>', self::DEFAULT_STORE_ID];
}
$stores = Store::where($where)->field('store_id,is_sync,is_recycle,status,is_delete')->select()->toArray();
if (!$stores) {
echo "没有要同步的商城了";
return;
}
foreach ($stores as $store) {
$this->copyCategory($store['store_id'], $is_update_image);
}
}
public function copyCategory(int $new_store_id, $is_update_image = 0){
$store_id = 0;
$model = new CategoryModel;
$list = $model->getList(['store_id' => self::DEFAULT_STORE_ID]);
// var_dump($list);
// exit();
if (!$list) {
return;
}
foreach ($list as $value) {
$value = $value->toArray();
if ($value['status'] != 1) {
continue;
}
$category = CategoryModel::where('original_category_id', $value['category_id'])->where('store_id', $new_store_id)->find();
if ($category) {
//更新分类
//父类id
if ($value['parent_id']) {
$p_category = CategoryModel::where('original_category_id', $value['parent_id'])->where('store_id', $new_store_id)->find();
}
$upData = [
'name' => $value['name'],
'level' => $value['level'],
'parent_id' => $p_category['category_id'] ?? 0,
];
if ($is_update_image) {
$upData['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0;
$upData['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0;
}
// var_dump($upData);
// exit();
$ret = CategoryModel::where('category_id', $category->category_id)->update($upData);
echo "更新成功".PHP_EOL;
var_dump($ret);
$firstid = $category->category_id;
} else {
//新增一个分类
$value['store_id'] = $new_store_id;
$value['create_time'] = time();
$value['update_time'] = time();
$value['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0;
$value['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0;
$value['original_category_id'] = $value['category_id'];
$temp = $value;
unset($temp['children']);
unset($temp['rankimage']);
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();
if ($value1['status'] != 1) {
continue;
}
$category1 = CategoryModel::where('original_category_id', $value1['category_id'])->where('store_id', $new_store_id)->find();
//var_dump($category1->toArray());
if ($category1) {
//更新分类
//父类id
$p_category1 = CategoryModel::where('original_category_id', $value1['parent_id'])->where('store_id', $new_store_id)->find();
// var_dump($p_category1);
// exit();
$upData1 = [
'name' => $value1['name'],
'level' => $value1['level'],
'parent_id' => $p_category1['category_id'] ?? 0,
];
if ($is_update_image) {
$upData1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0;
$upData1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0;
}
$ret = CategoryModel::where('category_id', $category1->category_id)->update($upData1);
echo "更新成功".PHP_EOL;
var_dump($ret);
$secondid = $category1->category_id;
} else {
//新增一个分类
$value1['parent_id'] = $firstid;
$value1['store_id'] = $new_store_id;
$value1['create_time'] = time();
$value1['update_time'] = time();
$value1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0;
$value1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0;
$value1['original_category_id'] = $value1['category_id'];
$temp1 = $value1;
unset($temp1['children']);
unset($temp1['image']);
unset($temp1['rankimage']);
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();
if ($value2['status'] != 1) {
continue;
}
$category2 = CategoryModel::where('original_category_id', $value2['category_id'])->where('store_id', $new_store_id)->find();
if ($category2) {
//更新分类
//父类id
$p_category2 = CategoryModel::where('original_category_id', $value2['parent_id'])->where('store_id', $new_store_id)->find();
$upData2 = [
'name' => $value2['name'],
'level' => $value2['level'],
'parent_id' => $p_category2['category_id'] ?? 0,
];
if ($is_update_image) {
$upData2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0;
$upData2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0;
}
$ret = CategoryModel::where('category_id', $category2->category_id)->update($upData2);
echo "更新成功".PHP_EOL;
var_dump($ret);
$thirdid = $category2->category_id;
} else {
//新增一个分类
$value2['parent_id'] = $secondid;
$value2['store_id'] = $new_store_id;
$value2['create_time'] = time();
$value2['update_time'] = time();
$value2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0;
$value2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0;
$value2['original_category_id'] = $value2['category_id'];
$temp2 = $value2;
unset($temp2['children']);
unset($temp2['image']);
unset($temp2['rankimage']);
unset($temp2['category_id']);
$thirdid = Db::table('yoshop_category')->insertGetId($temp2);
}
if (!isset($value2['children']) || !$value2['children']) {
continue;
}
foreach ($value2['children'] as $value3) {
$value3 = $value3->toArray();
if ($value3['status'] != 1) {
continue;
}
$category3 = CategoryModel::where('original_category_id', $value3['category_id'])->where('store_id', $new_store_id)->find();
if ($category3) {
//更新分类
//父类id
$p_category3 = CategoryModel::where('original_category_id', $value3['parent_id'])->where('store_id', $new_store_id)->find();
$upData3 = [
'name' => $value3['name'],
'level' => $value3['level'],
'parent_id' => $p_category3['category_id'] ?? 0,
];
if ($is_update_image) {
$upData3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0;
$upData3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0;
}
$ret = CategoryModel::where('category_id', $category3->category_id)->update($upData3);
echo "更新成功".PHP_EOL;
var_dump($ret);
$fourthid = $category3->category_id;
} else {
$value3['parent_id'] = $thirdid;
$value3['store_id'] = $new_store_id;
$value3['create_time'] = time();
$value3['update_time'] = time();
$value3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0;
$value3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0;
$value3['original_category_id'] = $value3['category_id'];
$temp3 = $value3;
unset($temp3['children']);
unset($temp3['image']);
unset($temp3['rankimage']);
unset($temp3['category_id']);
$fourthid = Db::table('yoshop_category')->insertGetId($temp3);
}
if (!isset($value3['children']) || !$value3['children']) {
continue;
}
foreach ($value3['children'] as $value4) {
$value4 = $value4->toArray();
if ($value4['status'] != 1) {
continue;
}
$category4 = CategoryModel::where('original_category_id', $value4['category_id'])->find();
if ($category4) {
//更新分类
//父类id
$p_category4 = CategoryModel::where('original_category_id', $value4['parent_id'])->find();
$upData4 = [
'name' => $value4['name'],
'level' => $value4['level'],
'parent_id' => $p_category4['category_id'] ?? 0,
];
if ($is_update_image) {
$upData4['image_id'] = $value4['image_id'] ? $this->copyImage($value4['image_id'], $new_store_id) : 0;
$upData4['rank_image_id'] = $value4['rank_image_id'] ? $this->copyImage($value4['rank_image_id'], $new_store_id) : 0;
}
$ret = CategoryModel::where('category_id', $category4->category_id)->update($upData4);
echo "更新成功".PHP_EOL;
var_dump($ret);
} else {
$value4['parent_id'] = $fourthid;
$value4['store_id'] = $new_store_id;
$value4['create_time'] = time();
$value4['update_time'] = time();
$value4['image_id'] = $value4['image_id'] ? $this->copyImage($value4['image_id'], $new_store_id) : 0;
$value4['rank_image_id'] = $value4['rank_image_id'] ? $this->copyImage($value4['rank_image_id'], $new_store_id) : 0;
$value4['original_category_id'] = $value4['category_id'];
$temp4 = $value4;
unset($temp4['children']);
unset($temp4['image']);
unset($temp4['rankimage']);
unset($temp4['category_id']);
Db::table('yoshop_category')->insertGetId($temp4);
}
}
}
}
}
}
}
public function copyImage($image_id, $store_id){
$upload_file = DB::table("yoshop_upload_file")->where('file_id', $image_id)->find();
if (!$upload_file) {
return 0;
}
$upload_file['store_id'] = $store_id;
$upload_file['create_time'] = time();
unset($upload_file['file_id']);
$new_image_id = DB::table("yoshop_upload_file")->insertGetId($upload_file);
return $new_image_id;
}
}

@ -626,7 +626,7 @@ class Goods extends BaseModel
$goodsInfo['channel_name'] = $channel['alias'] ?? "";
}
$goodsInfo['selling_point'] = "";
$goodsInfo['goods_images'] = helper::getArrayColumn($goodsInfo['images'], 'file');
// 商品主图
$goodsInfo['goods_image'] = $goodsInfo['goods_images'] ? current($goodsInfo['goods_images'])['preview_url'] : "";

@ -3,6 +3,7 @@
namespace app\common\model\user;
use cores\BaseModel;
use think\model\relation\BelongsTo;
class IdentityOrder extends BaseModel
{
@ -12,9 +13,30 @@ class IdentityOrder extends BaseModel
// 定义主键
protected $pk = 'order_id';
/**
/**
* 关联会员记录表
* @return BelongsTo
*/
public function user(): BelongsTo
{
$module = self::getCalledModule();
return $this->belongsTo("app\\{$module}\\model\\User");
}
// /**
// * 关联用户表
// * @return BelongsTo
// */
// public function user(): BelongsTo
// {
// return $this->belongsTo('User')->field(['user_id', 'nick_name', 'avatar_id']);
// }
public static function detail($where)
{
return self::get($where);
}
}

@ -14,7 +14,7 @@ namespace app\store\controller;
use app\store\model\Order as OrderModel;
use think\response\Json;
use app\common\model\UploadFile as UploadFileModel;
/**
* 订单管理
* Class Order
@ -67,6 +67,24 @@ class Order extends Controller
$data[$key]['address_match_text'] = '不匹配';
}
}
$merchant = null;
if ($value['merchant_id']) {
$merchant = \app\common\model\Merchant::detail($value['merchant_id'], $value['store_id']);
if ($merchant) {
if ($merchant['license_img_id']) {
$img_ids = explode(",", $merchant['license_img_id']);
$files = UploadFileModel::getFileList($img_ids, $value['store_id']);
$merchant['licenseImg'] = $files ?: null;
}
if ($merchant['logo_image_id']) {
$files = UploadFileModel::getFileList([$merchant['logo_image_id']], $value['store_id']);
$merchant['logoImage'] = $files ?: null;
}
}
}
$data[$key]['merchant'] = $merchant;
}
}
$list['current_page'] = $result->currentPage();

@ -95,6 +95,8 @@ class Presale extends Controller
// 评论详情
$model = PreSaleModel::get($id);
$data = $this->postForm();
// var_dump($data);
// exit();
// $data['p_time'] = format_time(time());
// 更新记录
if ($model->save($data)) {

@ -10,6 +10,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\Json;
use app\store\model\user\IdentityOrder;
class Identity extends Controller
{
@ -32,7 +33,20 @@ class Identity extends Controller
$list = $model->getList($where);
return $this->renderSuccess(compact('list'));
}
/**
* @notes:分销商价格
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function identityOrderList(): Json
{
$model = new IdentityOrder();
$list = $model->getList($this->request->param());
return $this->renderSuccess(compact('list'));
}
/**
* @notes:分销商价格
* @return Json

@ -0,0 +1,69 @@
<?php
namespace app\store\model\user;
use app\common\model\user\IdentityOrder as IdentityOrderModel;
class IdentityOrder extends IdentityOrderModel
{
/**
* 获取订单列表
* @param array $param
* @return \think\Paginator
*/
public function getList(array $param = []): \think\Paginator
{
// 设置查询条件
$filter = $this->getFilter($param);
// 获取列表数据
$list = $this->alias('order')
->field('order.*')
->where($filter)
->join('user', 'user.user_id = order.user_id')
->order(['order.create_time' => 'desc'])
->paginate($param['pageSize'] ?? 15);
// var_dump($list);
// exit();
//return $list;
// 加载订单的关联数据
return static::preload($list, ['user.avatar']);
}
/**
* 设置查询条件
* @param array $param
* @return array
*/
private function getFilter(array $param): array
{
// 设置默认的检索数据
$params = $this->setQueryDefaultValue($param, [
'user_id' => 0, // 用户ID
'search' => '', // 查询内容
'order_type' => 0, // 充值方式
'pay_method' => "", // 充值方式
'pay_status' => 0, // 支付状态
'betweenTime' => [] // 起止时间
]);
// 检索查询条件
$filter = [];
// 用户ID
$params['user_id'] > 0 && $filter[] = ['order.user_id', '=', $params['user_id']];
// 用户昵称/订单号
!empty($params['search']) && $filter[] = ['order.order_no|user.nick_name', 'like', "%{$params['search']}%"];
!empty($params['pay_method']) && $filter[] = ['order.pay_method', '=', $params['pay_method']];
// 充值方式
$params['order_type'] > 0 && $filter[] = ['order.order_type', '=', (int)$params['order_type']];
// 支付状态
$params['pay_status'] > 0 && $filter[] = ['order.pay_status', '=', (int)$params['pay_status']];
// 起止时间
if (!empty($params['pay_time'])) {
$times = between_time($params['pay_time']);
$filter[] = ['order.pay_time', '>=', $times['start_time']];
$filter[] = ['order.pay_time', '<', $times['end_time'] + 86400];
}
return $filter;
}
}

@ -15,5 +15,6 @@ return [
'syncGoodsToEs' => 'app\command\SyncGoodsToEs',
'ProfitSharing' => 'app\command\ProfitSharing',
'ProfitSharingResult' => 'app\command\ProfitSharingResult',
'SyncCategory' => 'app\command\SyncCategory',
],
];

Loading…
Cancel
Save