鲜花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;
|
||||||
/**
|
/**
|
||||||
* 数组中的属性会被隐藏。
|
* 数组中的属性会被隐藏。
|
||||||
*
|
*
|
||||||
|
|||||||
@ -150,11 +150,11 @@ class KuaiTuanTuan extends BusinessClient
|
|||||||
$shopId = $this->getShop()->id;
|
$shopId = $this->getShop()->id;
|
||||||
$now = Carbon::now()->toDateTimeString();
|
$now = Carbon::now()->toDateTimeString();
|
||||||
foreach ($orders as $k => $v) {
|
foreach ($orders as $k => $v) {
|
||||||
$model = BusinessAfterSaleOrder::query()->where("shop_id","=",$shopId)
|
$model = BusinessAfterSaleOrder::query()->where("shop_id", "=", $shopId)
|
||||||
->where("after_sales_biz_sn", "=", $v['after_sales_biz_sn'])->first();
|
->where("after_sales_biz_sn", "=", $v['after_sales_biz_sn'])->first();
|
||||||
if (empty($model)) {
|
if (empty($model)) {
|
||||||
$model = new BusinessAfterSaleOrder();
|
$model = new BusinessAfterSaleOrder();
|
||||||
}else{
|
} else {
|
||||||
$model->updated_at = $now;
|
$model->updated_at = $now;
|
||||||
}
|
}
|
||||||
$model->shop_id = $shopId;
|
$model->shop_id = $shopId;
|
||||||
@ -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
|
||||||
|
|||||||
@ -34,8 +34,18 @@ 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")
|
||||||
@ -61,10 +71,13 @@ 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)) {
|
||||||
, DB::raw("sum(order_total_amount) as goods_total_amount"))
|
$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"))
|
||||||
->whereBetween("created_at", [$startTime, $endTime])
|
->whereBetween("created_at", [$startTime, $endTime])
|
||||||
->groupBy("sku_id")
|
->groupBy("sku_id")
|
||||||
->having(DB::raw("sum(order_goods_num)"), ">", 0)
|
->having(DB::raw("sum(order_goods_num)"), ">", 0)
|
||||||
@ -147,20 +160,20 @@ class SaleDataService
|
|||||||
|
|
||||||
public static function getTimeRange(Request $request)
|
public static function getTimeRange(Request $request)
|
||||||
{
|
{
|
||||||
if(!empty($request->input("start_time"))&&!empty($request->input("start_time"))){
|
if (!empty($request->input("start_time")) && !empty($request->input("start_time"))) {
|
||||||
$startTime = Carbon::parse($request->input("start_time"))->toDateTimeString();
|
$startTime = Carbon::parse($request->input("start_time"))->toDateTimeString();
|
||||||
$endTime = Carbon::parse($request->input("end_time"))->toDateTimeString();
|
$endTime = Carbon::parse($request->input("end_time"))->toDateTimeString();
|
||||||
}else{
|
} else {
|
||||||
$startTime = Carbon::parse($request->input("start_day"))->toDateTimeString();
|
$startTime = Carbon::parse($request->input("start_day"))->toDateTimeString();
|
||||||
$endTime = Carbon::parse($request->input("end_day"))->endOfDay()->toDateTimeString();
|
$endTime = Carbon::parse($request->input("end_day"))->endOfDay()->toDateTimeString();
|
||||||
}
|
}
|
||||||
return [$startTime,$endTime];
|
return [$startTime, $endTime];
|
||||||
}
|
}
|
||||||
|
|
||||||
public
|
public
|
||||||
static function spuSaleStatisticsByToday(Request $request)
|
static function spuSaleStatisticsByToday(Request $request)
|
||||||
{
|
{
|
||||||
[$startTime,$endTime] = static::getTimeRange($request);
|
[$startTime, $endTime] = static::getTimeRange($request);
|
||||||
//实时统计 sku维度
|
//实时统计 sku维度
|
||||||
$orderItems = BusinessOrderItem::query()
|
$orderItems = BusinessOrderItem::query()
|
||||||
->leftJoin("business_orders as b", "business_order_id", "=", "b.id")
|
->leftJoin("business_orders as b", "business_order_id", "=", "b.id")
|
||||||
@ -208,7 +221,7 @@ class SaleDataService
|
|||||||
public
|
public
|
||||||
static function spuSaleStatisticsByHistoryCache(Request $request)
|
static function spuSaleStatisticsByHistoryCache(Request $request)
|
||||||
{
|
{
|
||||||
[$startTime,$endTime] = static::getTimeRange($request);
|
[$startTime, $endTime] = static::getTimeRange($request);
|
||||||
$cacheKey = CacheKeyEnum::SPU_STATISTIC_BY_DATE . $request->input("start_day") . "_" . $request->input("end_day");
|
$cacheKey = CacheKeyEnum::SPU_STATISTIC_BY_DATE . $request->input("start_day") . "_" . $request->input("end_day");
|
||||||
$expireTime = Carbon::now()->addHour();
|
$expireTime = Carbon::now()->addHour();
|
||||||
return Cache::remember($cacheKey, $expireTime, function () use ($startTime, $endTime) {
|
return Cache::remember($cacheKey, $expireTime, function () use ($startTime, $endTime) {
|
||||||
@ -260,7 +273,7 @@ class SaleDataService
|
|||||||
static function gmvStatistics(Request $request)
|
static function gmvStatistics(Request $request)
|
||||||
{
|
{
|
||||||
if (StaticTypeEnum::TODAY == $request->type) {
|
if (StaticTypeEnum::TODAY == $request->type) {
|
||||||
[$startTime,$endTime] = static::getTimeRange($request);
|
[$startTime, $endTime] = static::getTimeRange($request);
|
||||||
$build = BusinessOrderItem::query();
|
$build = BusinessOrderItem::query();
|
||||||
if (!empty($request->sku_id)) {
|
if (!empty($request->sku_id)) {
|
||||||
$externalSkuId = GoodsSku::query()->where("id", "=", $request->sku_id)
|
$externalSkuId = GoodsSku::query()->where("id", "=", $request->sku_id)
|
||||||
@ -291,8 +304,8 @@ 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)) {
|
||||||
$build->where("sku_id", "=", $request->sku_id);
|
$build->where("sku_id", "=", $request->sku_id);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user