lqmac 7 months ago
parent 83f9a7c685
commit 9e44c450c7
  1. 15
      app/admin/controller/Goods.php
  2. 7
      app/api/controller/Dealer.php
  3. 15
      app/api/controller/Goods.php
  4. 3
      app/common/model/Goods.php
  5. 43
      app/store/controller/Goods.php
  6. 4
      app/store/controller/order/Refund.php
  7. 11
      app/store/model/Goods.php
  8. 1
      app/store/model/Order.php

@ -201,7 +201,20 @@ class Goods extends Controller
} }
return $this->renderSuccess('操作成功'); return $this->renderSuccess('操作成功');
} }
/**
* 修改商品状态(上下架)
* @param array $goodsIds 商品id集
* @param bool $state 为true表示上架
* @return Json
*/
public function jingpin(array $goodsIds, int $is_jingpin): Json
{
$model = new GoodsModel;
if (!$model->setIsJingpin($goodsIds, $is_jingpin)) {
return $this->renderError($model->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
/** /**
* 修改商品状态(上下架) * 修改商品状态(上下架)
* @param array $goodsIds 商品id集 * @param array $goodsIds 商品id集

@ -61,8 +61,11 @@ class Dealer extends Controller
*/ */
public function center(): Json public function center(): Json
{ {
$dealer = isset($this->dealer) ? $this->dealer->toArray() : null; $dealer = $this->dealer;
if (!$dealer) {
return $this->renderError('您没有购买分销会员');
}
$dealer = $dealer->toArray();
$dealer['update_time'] = date("Y-m-d", strtotime($dealer['update_time'])); $dealer['update_time'] = date("Y-m-d", strtotime($dealer['update_time']));
// 获取用户头像 // 获取用户头像

@ -86,9 +86,20 @@ class Goods extends Controller
foreach ($params['list'] as $value) { foreach ($params['list'] as $value) {
$res = "无货"; $res = "无货";
$goods = GoodsModel::where('goods_id', $value['goods_id'])->find(); $goods = GoodsModel::where('goods_id', $value['goods_id'])->find();
//限制销售区域
$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find();
if ($goods['region'] && !in_array($city->id, json_decode($goods['region']))) {
$data = [
'state' => "无货",
'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'],
];
$return[] = $data;
continue;
}
switch ($goods->channel) { switch ($goods->channel) {
case 'sn': case 'sn':
$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find(); //$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find();
$district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find(); $district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find();
$suning = new \app\common\service\Suning(); $suning = new \app\common\service\Suning();
$goods->num = $param['num'] ?? 1; $goods->num = $param['num'] ?? 1;
@ -98,7 +109,7 @@ class Goods extends Controller
break; break;
case 'jd': case 'jd':
$province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find(); $province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find();
$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find(); //$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find();
$district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find(); $district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find();
$jd = new \app\common\service\Jd(); $jd = new \app\common\service\Jd();
$arr = []; $arr = [];

@ -469,6 +469,9 @@ class Goods extends BaseModel
if (isset($param['is_pool']) && $param['is_pool'] !== '') { if (isset($param['is_pool']) && $param['is_pool'] !== '') {
$filter[] = ['goods.is_pool', '=', $params['is_pool']]; $filter[] = ['goods.is_pool', '=', $params['is_pool']];
} }
if (isset($param['is_jingpin']) && $param['is_jingpin'] !== '') {
$filter[] = ['goods.is_jingpin', '=', $params['is_jingpin']];
}
if (isset($param['start_time']) && $param['start_time'] !== '') { if (isset($param['start_time']) && $param['start_time'] !== '') {
$filter[] = ['goods.create_time', '>=', strtotime($params['start_time'])]; $filter[] = ['goods.create_time', '>=', strtotime($params['start_time'])];
} }

@ -16,6 +16,7 @@ use think\db\exception\DbException;
use think\response\Json; use think\response\Json;
use cores\exception\BaseException; use cores\exception\BaseException;
use app\store\model\Goods as GoodsModel; use app\store\model\Goods as GoodsModel;
use app\store\model\goods\Import as ImportModel;
/** /**
* 商品管理控制器 * 商品管理控制器
@ -151,4 +152,46 @@ class Goods extends Controller
} }
return $this->renderSuccess('删除成功'); return $this->renderSuccess('删除成功');
} }
public function export(){
$model = new GoodsModel;
$params = $this->request->param();
$params['store_id'] = $this->storeId;
$perSize = 10000;
$params['page'] = 1;
$params['channels'] = ['zy'];
$data = $model->getAdminListExport($params, $perSize)->toArray();
// echo "<pre>";
// print_r($data);
// exit();
$titles = [
['goods_id'=>'系统编码'],
['goods_name'=>'标题'],
['cmmdty_model'=>'型号'],
['link'=>'该商品苏宁的链接'],
['cost_price_min'=>'成本价'],
['stock_total'=>'库存'],
['link_other'=>'京东的价拖链接'],
['goods_price_min'=>'前台价'],
];
downLoadExcel('导出数据-'.date('Y-m-d', time()),$titles,$data['data']);
}
public function import(){
// 新增记录
$model = new ImportModel;
$params = $this->postData();
$params['channel'] = "zy";
if ($model->goodsUpdateBatch($params)) {
return $this->renderSuccess('已添加到导入任务中,请在历史导入记录中查看结果');
}
return $this->renderError($model->getError() ?: '操作失败');
}
} }

@ -43,9 +43,11 @@ class Refund extends Controller
{ {
// 售后单详情 // 售后单详情
$model = new OrderRefundModel; $model = new OrderRefundModel;
if (!$detail = $model->getDetail($orderRefundId)) { $detail = $model->getDetail($orderRefundId);
if (!$detail) {
return $this->renderError('未找到该售后单记录'); return $this->renderError('未找到该售后单记录');
} }
$detail->refuse_desc = $detail->refuse_desc ? htmlspecialchars_decode($detail->refuse_desc) : "";
return $this->renderSuccess(compact('detail')); return $this->renderSuccess(compact('detail'));
} }

@ -192,6 +192,17 @@ class Goods extends GoodsModel
// 批量更新记录 // 批量更新记录
return static::updateBase(['is_sale' => $is_sale], [['goods_id', 'in', $goodsIds]]); return static::updateBase(['is_sale' => $is_sale], [['goods_id', 'in', $goodsIds]]);
} }
/**
* 修改商品状态
* @param array $goodsIds 商品id集
* @param bool $state 为true表示上架
* @return bool|false
*/
public function setIsJingpin(array $goodsIds, int $is_sale): bool
{
// 批量更新记录
return static::updateBase(['is_jingpin' => $is_sale], [['goods_id', 'in', $goodsIds]]);
}
/** /**
* 修改商品状态 * 修改商品状态
* @param array $goodsIds 商品id集 * @param array $goodsIds 商品id集

@ -47,6 +47,7 @@ class Order extends OrderModel
'extract_clerk', 'extract_clerk',
'trade', 'trade',
]); ]);
$order->merchant_remark = $order->merchant_remark ? htmlspecialchars_decode($order->merchant_remark) : "";
// 附加数据 // 附加数据
static::related($order, ['user', 'address', 'express', 'extract']); static::related($order, ['user', 'address', 'express', 'extract']);
return $order; return $order;

Loading…
Cancel
Save