lqmac 5 months ago
parent 31fb6a64ca
commit 6f7921636e
  1. 2
      app/admin/controller/Goods.php
  2. 18
      app/admin/controller/Store.php
  3. 47
      app/api/controller/Goods.php
  4. 3
      app/common.php
  5. 6
      app/common/model/PriceSet.php
  6. 3
      app/common/service/Jd.php
  7. 1
      config/module.php

@ -174,6 +174,8 @@ class Goods extends Controller
'goods_source' => $goods_sku->goods_source, 'goods_source' => $goods_sku->goods_source,
'is_check' => $goods_sku->is_check, 'is_check' => $goods_sku->is_check,
'delivery_time' => $goods_sku->delivery_time, 'delivery_time' => $goods_sku->delivery_time,
'is_use_jd_stock' => $goods_sku->is_use_jd_stock,
'is_jd_remove' => $goods_sku->is_jd_remove,
// 'is_pool' => $goods_sku->is_pool, // 'is_pool' => $goods_sku->is_pool,
// 'is_sale' => $goods_sku->is_sale, // 'is_sale' => $goods_sku->is_sale,
'update_time' => time(), 'update_time' => time(),

@ -374,7 +374,7 @@ class Store extends Controller
*/ */
public function deleteGoods(int $storeId): Json public function deleteGoods(int $storeId): Json
{ {
ini_set('memory_limit', '2024M'); ini_set('memory_limit', '1024M');
set_time_limit(0); set_time_limit(0);
$model = StoreModel::detail($storeId); $model = StoreModel::detail($storeId);
if (!$model || $storeId <= 0) { if (!$model || $storeId <= 0) {
@ -389,9 +389,16 @@ class Store extends Controller
// GoodsModel::where('store_id', $storeId)->delete(); // GoodsModel::where('store_id', $storeId)->delete();
$page = 1; $page = 1;
while (TRUE) { while (TRUE) {
$goods_list = GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->field('goods_id')->page($page)->limit(2000)->select(); //echo $page.PHP_EOL;
$goods_list = GoodsModel::where('store_id', $storeId)
->where('channel','<>', 'zy')
->field('goods_id')
->order("goods_id desc")
->page($page)
->limit(2000)
->select();
if ($goods_list->isEmpty()) { if ($goods_list->isEmpty()) {
return $this->renderSuccess(); break;
} }
$goods_ids = array_column($goods_list->toArray(), "goods_id"); $goods_ids = array_column($goods_list->toArray(), "goods_id");
//删除商品sku //删除商品sku
@ -400,10 +407,11 @@ class Store extends Controller
GoodsImage::whereIn('goods_id', $goods_ids)->delete(); GoodsImage::whereIn('goods_id', $goods_ids)->delete();
//删除商品规格 //删除商品规格
GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete(); GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete();
//删除商品
GoodsModel::whereIn('goods_id', $goods_ids)->delete();
$page++; $page++;
} }
//删除商品
GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->delete();
return $this->renderSuccess(); return $this->renderSuccess();
} }

@ -124,9 +124,7 @@ class Goods extends Controller
case 'jd': case 'jd':
case 'jd1': case 'jd1':
case 'jd2': case 'jd2':
case 'zy':
$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();
$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 = [];
@ -152,16 +150,43 @@ class Goods extends Controller
]; ];
break; break;
default: default:
if ($goods->is_use_jd_stock) {//是否使用京东库存
if ($goods->stock_total >= ($value['num'] ?? 1)) { $province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find();
$res = "有货"; $district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find();
$jd = new \app\common\service\Jd();
$arr = [];
$ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $value['num'] ?? 1);
// echo "<pre>";
// print_r($ret);
//var_dump($ret);
if ($ret) {
$res = $ret['stockResp']['desc'] ?? "无货";
if (strpos($res, "无货") !== false) {
$res = "无货";
} elseif (strpos($res, "有货") == false) {
$res = "有货";
}
}
$data = [
'state' => $res,
'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'],
//'promise_info' => $ret['promiseInfo'] ?? "预计72小时内发货",
'promise_info' => "预计48小时内发货",
];
} else {
if ($goods->stock_total >= ($value['num'] ?? 1)) {
$res = "有货";
}
$data = [
'state' => $res,
'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'],
'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']]['name'] ?? "72小时")."内发货",
];
} }
$data = [
'state' => $res,
'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'],
'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']]['name'] ?? "72小时")."内发货",
];
break; break;
} }

@ -621,7 +621,8 @@ function getGoodsCostAndProfitAndProfitRate($net_price, $cost_price, $rate){
*/ */
function getJdGoodsBySku($skus){ function getJdGoodsBySku($skus){
$sku = implode(",", $skus); $sku = implode(",", $skus);
$url = "http://47.98.251.206:8811/api/skus/info?skus=".$sku; //$url = "http://47.98.251.206:8811/api/skus/info?skus=".$sku;
$url = "http://8.130.98.31:8811/api/skus/info?skus=".$sku;
$data = httpRequest($url, "GET", null, [], false, 30); $data = httpRequest($url, "GET", null, [], false, 30);
if ($data['code'] != 0 || !$data['data']) { if ($data['code'] != 0 || !$data['data']) {

@ -43,7 +43,8 @@ class PriceSet extends BaseModel
//return sprintf("%.2f", $market_price); //return sprintf("%.2f", $market_price);
return round($market_price); return round($market_price);
} }
$membershipPrice = $cost_price * (1 + $addPriceRate * 0.01); //$membershipPrice = $cost_price * (1 + $addPriceRate * 0.01);
$membershipPrice = $cost_price / (1 - $addPriceRate * 0.01);
//当加价率生效后,会员价高于市场价 //当加价率生效后,会员价高于市场价
if ($membershipPrice > $market_price) { if ($membershipPrice > $market_price) {
$membershipPrice = ($market_price - $cost_price) * $addPriceRate * 0.01 + $cost_price; $membershipPrice = ($market_price - $cost_price) * $addPriceRate * 0.01 + $cost_price;
@ -74,7 +75,8 @@ class PriceSet extends BaseModel
$arr['distributionPrice'] = round($market_price); $arr['distributionPrice'] = round($market_price);
return $arr; return $arr;
} }
$distributionPrice = $cost_price * (1 + $addPriceRate * 0.01); //$distributionPrice = $cost_price * (1 + $addPriceRate * 0.01);
$distributionPrice = $cost_price / (1 - $addPriceRate * 0.01);
$price = $distributionPrice; $price = $distributionPrice;
//当加价率生效后,分销价高于市场价 //当加价率生效后,分销价高于市场价
if ($distributionPrice > $market_price) { if ($distributionPrice > $market_price) {

@ -65,7 +65,8 @@ class Jd extends BaseService {
* @return [type] [description] * @return [type] [description]
*/ */
public function getGoodsMainImageAndDetail($skuId){ public function getGoodsMainImageAndDetail($skuId){
$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId="; //$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId=";
$url = "http://8.130.98.31:8811/api/goods/info/v2?sku=".$skuId."&areaId=";
$res = httpRequest($url); $res = httpRequest($url);
if ($res && $res['code'] == 0 && isset($res['data'])) { if ($res && $res['code'] == 0 && isset($res['data'])) {
return $res['data']; return $res['data'];

@ -32,6 +32,7 @@ return [
'children' => [ 'children' => [
'merchant' => ['name' => '商户管理', 'enable' => true], 'merchant' => ['name' => '商户管理', 'enable' => true],
'merchant-manage' => ['name' => '商户列表', 'enable' => true], 'merchant-manage' => ['name' => '商户列表', 'enable' => true],
'merchant-cate' => ['name' => '商户分类', 'enable' => true],
] ]
], ],
'goods' => [ 'goods' => [

Loading…
Cancel
Save