鲜花2.0-类型软删除+统计接口修改
This commit is contained in:
parent
267e5ab5cd
commit
465b93e035
@ -194,7 +194,7 @@ class GoodsCombinationController extends Controller
|
|||||||
public function goodsSkus(Request $request, $title)
|
public function goodsSkus(Request $request, $title)
|
||||||
{
|
{
|
||||||
$skus = GoodsSku::query()
|
$skus = GoodsSku::query()
|
||||||
->where('title', 'like', '%' . $title . '%')
|
->where('name', 'like', '%' . $title . '%')
|
||||||
->where('is_combination', 0)
|
->where('is_combination', 0)
|
||||||
->with('goods:id,title')
|
->with('goods:id,title')
|
||||||
->get(['id', 'title', 'goods_id']);
|
->get(['id', 'title', 'goods_id']);
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class GoodsController extends Controller
|
|||||||
$item['reference_price'] = $item['cost'] * 1.5;
|
$item['reference_price'] = $item['cost'] * 1.5;
|
||||||
$item['sku_code'] = !empty($item['sku_code']) ? $item['sku_code'] : $goodService->getRandomCode();
|
$item['sku_code'] = !empty($item['sku_code']) ? $item['sku_code'] : $goodService->getRandomCode();
|
||||||
$item['external_sku_id'] = $goods->goods_code . '_' .$item['sku_code'];
|
$item['external_sku_id'] = $goods->goods_code . '_' .$item['sku_code'];
|
||||||
$item['name'] = $goods->title . $item['title'];
|
$item['name'] = $goods->title ." ". $item['title'];
|
||||||
$goodsSkus[] = $item;
|
$goodsSkus[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class MessageTypeEnum
|
|||||||
|
|
||||||
const QUALITY_PERIOD_EXPIRE_NOTICE = "quality_period_expire_notice";
|
const QUALITY_PERIOD_EXPIRE_NOTICE = "quality_period_expire_notice";
|
||||||
|
|
||||||
const DEFAULT_ROLE_IDS = [9];
|
const DEFAULT_ROLE_IDS = [11];
|
||||||
|
|
||||||
const MESSAGE_ALL_TYPE = [
|
const MESSAGE_ALL_TYPE = [
|
||||||
self::LOW_STOCK_NOTICE,
|
self::LOW_STOCK_NOTICE,
|
||||||
|
|||||||
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class GoodsType extends Model
|
class GoodsType extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
/**
|
/**
|
||||||
* 数组中的属性会被隐藏。
|
* 数组中的属性会被隐藏。
|
||||||
*
|
*
|
||||||
|
|||||||
@ -215,6 +215,7 @@ class KuaiTuanTuan extends BusinessClient
|
|||||||
$publicParams = array_merge($publicParams, $appendParams);
|
$publicParams = array_merge($publicParams, $appendParams);
|
||||||
$publicParams['sign'] = $this->getSign($publicParams);
|
$publicParams['sign'] = $this->getSign($publicParams);
|
||||||
$res = $this->formDataPostRequest($url, $publicParams);
|
$res = $this->formDataPostRequest($url, $publicParams);
|
||||||
|
Log::info("快团团请求", ["param" => $publicParams, "res" => $res]);
|
||||||
if (isset($res['error_response'])) {
|
if (isset($res['error_response'])) {
|
||||||
// "error_msg":"业务服务错误","sub_msg":"该店铺下不存在该商品","sub_code":"11","error_code":50001
|
// "error_msg":"业务服务错误","sub_msg":"该店铺下不存在该商品","sub_code":"11","error_code":50001
|
||||||
// "error_msg":"业务服务错误","sub_msg":"该SKU在快团团中设置的库存为无限库存,不支持修改库存","sub_code":"13","error_code":50001
|
// "error_msg":"业务服务错误","sub_msg":"该SKU在快团团中设置的库存为无限库存,不支持修改库存","sub_code":"13","error_code":50001
|
||||||
|
|||||||
@ -35,7 +35,17 @@ class SaleDataService
|
|||||||
public static function skuSaleStatisticsByToday(Request $request)
|
public static function skuSaleStatisticsByToday(Request $request)
|
||||||
{
|
{
|
||||||
[$startTime, $endTime] = static::getTimeRange($request);
|
[$startTime, $endTime] = static::getTimeRange($request);
|
||||||
$orderItems = BusinessOrderItem::query()
|
$build = BusinessOrderItem::query();
|
||||||
|
if (!empty($request->sku_id)) {
|
||||||
|
$externalSkuId = GoodsSku::query()->where("id", "=", $request->sku_id)
|
||||||
|
->pluck("external_sku_id")->first();
|
||||||
|
if (!empty($externalSkuId)) {
|
||||||
|
$build->where("external_sku_id", "=", $externalSkuId);
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$orderItems = $build
|
||||||
->leftJoin("business_orders as b", "business_order_id", "=", "b.id")
|
->leftJoin("business_orders as b", "business_order_id", "=", "b.id")
|
||||||
->select("business_order_items.external_sku_id"
|
->select("business_order_items.external_sku_id"
|
||||||
, DB::raw("sum(CASE WHEN b.shipping_status>0 THEN goods_number-already_cancel_number ELSE 0 END) as shipping_num")
|
, DB::raw("sum(CASE WHEN b.shipping_status>0 THEN goods_number-already_cancel_number ELSE 0 END) as shipping_num")
|
||||||
@ -62,8 +72,11 @@ class SaleDataService
|
|||||||
public static function skuSaleStatisticsByHistory(Request $request)
|
public static function skuSaleStatisticsByHistory(Request $request)
|
||||||
{
|
{
|
||||||
[$startTime, $endTime] = static::getTimeRange($request);
|
[$startTime, $endTime] = static::getTimeRange($request);
|
||||||
$dailyRecord = DailyStockRecord::query()
|
$build = DailyStockRecord::query();
|
||||||
->select("sku_id", DB::raw("sum(order_goods_num) as goods_total")
|
if (!empty($request->sku_id)) {
|
||||||
|
$build->where("sku_id", "=", $request->sku_id);
|
||||||
|
}
|
||||||
|
$dailyRecord = $build->select("sku_id", DB::raw("sum(order_goods_num) as goods_total")
|
||||||
, DB::raw("sum(order_total_amount) as goods_total_amount"))
|
, DB::raw("sum(order_total_amount) as goods_total_amount"))
|
||||||
->whereBetween("created_at", [$startTime, $endTime])
|
->whereBetween("created_at", [$startTime, $endTime])
|
||||||
->groupBy("sku_id")
|
->groupBy("sku_id")
|
||||||
@ -291,7 +304,7 @@ class SaleDataService
|
|||||||
];
|
];
|
||||||
})->sort()->values()->toArray();
|
})->sort()->values()->toArray();
|
||||||
} else {
|
} else {
|
||||||
//gmv 目前只统计历史数据 后续看看是否需要拓展
|
//gmv 统计历史数据
|
||||||
[$startTime, $endTime] = static::getTimeRange($request);
|
[$startTime, $endTime] = static::getTimeRange($request);
|
||||||
$build = DailyStockRecord::query();
|
$build = DailyStockRecord::query();
|
||||||
if (!empty($request->sku_id)) {
|
if (!empty($request->sku_id)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user