Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
781c1560
Commit
781c1560
authored
Aug 23, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' of
https://gitlab.yidian-inc.com/bp/goods
into test
parents
debcc356
fade0179
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
6 deletions
+117
-6
GoodsException.php
application/exception/custom/GoodsException.php
+3
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+10
-0
Marketingfororder.php
...ation/modules/Marketing/controllers/Marketingfororder.php
+11
-2
GoodsService.php
application/services/goods/GoodsService.php
+26
-0
MarketingPindanGoodsService.php
application/services/goods/MarketingPindanGoodsService.php
+21
-2
MarketingForOrderService.php
application/services/marketing/MarketingForOrderService.php
+2
-2
MarketingService.php
application/services/marketing/MarketingService.php
+44
-0
No files found.
application/exception/custom/GoodsException.php
View file @
781c1560
...
...
@@ -14,6 +14,7 @@ class GoodsException extends BaseException
const
PRINTER_ALREADY_EXIST
=
36
;
const
EMPTY_OTA_ID
=
37
;
const
OTA_NOT_EXIST
=
38
;
const
RULE_LIMIT_ERROR
=
50
;
protected
$cus
=
[
0
=>
'商品创建失败,请稍后重试'
,
...
...
@@ -65,5 +66,7 @@ class GoodsException extends BaseException
46
=>
'已经执行过cancel'
,
47
=>
'sku rollback error'
,
48
=>
'请满足以下条件后提交,售价-分销总金额-手续费>=结算价'
,
49
=>
'库存不得小于已售库存'
,
self
::
RULE_LIMIT_ERROR
=>
'单人可买上限填写错误'
,
];
}
\ No newline at end of file
application/modules/Goods/controllers/Goods.php
View file @
781c1560
...
...
@@ -314,4 +314,14 @@ class GoodsController extends Base
$res
=
GoodsSnapshotsService
::
pindanGoodsSnapshots
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
}
/**
* 通过goods_sku_id 获取 拼单商品的ota信息
* @throws Exception
*/
public
function
take_place_by_goods_sku_idsAction
()
{
$res
=
GoodsService
::
getOtaInfoByGoodsSkuIds
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
}
}
\ No newline at end of file
application/modules/Marketing/controllers/Marketingfororder.php
View file @
781c1560
...
...
@@ -34,8 +34,17 @@ class MarketingfororderController extends Base
public
function
take_place_listAction
()
{
$params
=
$this
->
params
;
$data
=
MarketingForOrderService
::
getMarketingTakePlaceList
(
$params
);
$this
->
success
([
"result"
=>
$data
]);
$takePlaceList
=
MarketingForOrderService
::
getMarketingTakePlaceList
(
$params
);
$addressList
=
[];
//
if
(
!
empty
(
$takePlaceList
))
$addressList
=
array_unique
(
array_column
(
$takePlaceList
,
'address'
));
//
$this
->
success
([
"result"
=>
[
'take_place_list'
=>
$takePlaceList
,
'address_list'
=>
$addressList
]]);
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
781c1560
...
...
@@ -20,6 +20,7 @@ use App\Models\goods\mysql\GoodsSkuSubShop;
use
App\Models\goods\mysql\GoodsSnapshot
;
use
App\Models\goods\mysql\GoodsSpu
;
use
App\Models\goods\mysql\LifeAccountShopNum
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\PaySuccessGoodsCallbackRecord
;
use
App\Models\goods\mysql\PindanGoodsSku
;
use
App\Models\goods\mysql\Shop
;
...
...
@@ -1757,4 +1758,29 @@ class GoodsService
}
return
true
;
}
/**
* 通过goods_sku_id 获取 拼单商品的ota信息
* @param array $params
* @return array
*/
public
static
function
getOtaInfoByGoodsSkuIds
(
$params
=
[])
{
$data
=
[];
$goodsSkuIds
=
empty
(
$params
[
"goods_sku_ids"
])
?
[]
:
$params
[
"goods_sku_ids"
];
if
(
!
empty
(
$goodsSkuIds
))
{
$pindanGoodsSkus
=
PindanGoodsSku
::
select
([
"goods_sku_id"
,
"ota_id"
],
[
"goods_sku_id"
=>
$goodsSkuIds
]);
$otaIds
=
array_column
(
$pindanGoodsSkus
,
"ota_id"
);
$otaInfos
=
Ota
::
select
(
"*"
,
[
"ota_id"
=>
$otaIds
]);
$otaIds
=
array_column
(
$otaInfos
,
"ota_id"
);
$otaInfos
=
array_column
(
$otaInfos
,
null
,
"ota_id"
);
foreach
(
$pindanGoodsSkus
as
$sku
)
{
if
(
in_array
(
$sku
[
"ota_id"
],
$otaIds
))
{
$data
[
$sku
[
"goods_sku_id"
]]
=
$otaInfos
[
$sku
[
"ota_id"
]];
}
}
}
return
$data
;
}
}
\ No newline at end of file
application/services/goods/MarketingPindanGoodsService.php
View file @
781c1560
...
...
@@ -143,6 +143,7 @@ class MarketingPindanGoodsService
"goods_name"
=>
$spuData
[
"marketing_name"
],
"desc_pic_url"
=>
$spuData
[
"desc_pic_url"
],
"desc"
=>
$spuData
[
"desc"
],
"rule_limit"
=>
empty
(
$skuData
[
"rule_limit"
])
?
0
:
$skuData
[
"rule_limit"
],
"goods_type"
=>
empty
(
$spuData
[
"goods_type"
])
?
GoodsSpu
::
TYPE_ENTITY
:
$spuData
[
"goods_type"
],
"goods_sub_type"
=>
empty
(
$spuData
[
"goods_sub_type"
])
?
GoodsSpu
::
SUB_TYPE_INSTANT
:
$spuData
[
"goods_sub_type"
],
"belong_type"
=>
empty
(
$spuData
[
"belong_type"
])
?
GoodsSpu
::
BELONG_TYPE_DISANFANG
:
$spuData
[
"belong_type"
],
...
...
@@ -191,6 +192,12 @@ class MarketingPindanGoodsService
if
(
$checkGoodsDesc
)
{
throw
new
GoodsException
([
'cus'
=>
20
]);
}
//判断是否是整数
if
(
!
empty
(
$skuData
[
"rule_limit"
])
&&
(
!
is_numeric
(
$skuData
[
"rule_limit"
])
||
strpos
(
$skuData
[
"rule_limit"
],
"."
)
!==
false
))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
RULE_LIMIT_ERROR
]);
}
$skuParams
=
[
"goods_sku_id"
=>
$skuId
,
"goods_spu_id"
=>
$spuData
[
"goods_spu_id"
],
...
...
@@ -202,6 +209,7 @@ class MarketingPindanGoodsService
"goods_name"
=>
$skuData
[
"goods_name"
],
"desc_pic_url"
=>
$skuData
[
"desc_pic_url"
],
"desc"
=>
$skuData
[
"desc"
],
"rule_limit"
=>
empty
(
$skuData
[
"rule_limit"
])
?
0
:
$skuData
[
"rule_limit"
],
"inventory_total"
=>
$skuData
[
"inventory"
],
"inventory_rest"
=>
$skuData
[
"inventory"
],
"original_price"
=>
empty
(
$skuData
[
"original_price"
])
?
""
:
$skuData
[
"original_price"
]
*
100
,
...
...
@@ -267,6 +275,7 @@ class MarketingPindanGoodsService
return
GoodsSpu
::
save
([
"desc_pic_url"
=>
$params
[
"desc_pic_url"
],
"desc"
=>
$params
[
"desc"
],
"rule_limit"
=>
empty
(
$params
[
"rule_limit"
])
?
0
:
$params
[
"rule_limit"
],
],
[
"goods_spu_id"
=>
$goodsSpu
[
"goods_spu_id"
]]);
}
...
...
@@ -282,7 +291,12 @@ class MarketingPindanGoodsService
private
static
function
editGoodsSku
(
$goodsSkuId
,
$skuData
,
$params
=
[])
{
$inventoryCount
=
$skuData
[
"inventory_rest"
]
+
$params
[
"inventory_add"
];
//$inventoryCount = $params["inventory"];
$inventoryTotal
=
$skuData
[
"inventory_total"
]
+
$params
[
"inventory_add"
];
if
(
$inventoryTotal
<
$skuData
[
"inventory_lock"
]
+
$skuData
[
"total_amount_order"
])
{
throw
new
GoodsException
([
'cus'
=>
49
]);
}
if
(
$inventoryCount
<
0
)
{
throw
new
GoodsException
([
'cus'
=>
18
]);
}
...
...
@@ -303,12 +317,17 @@ class MarketingPindanGoodsService
throw
new
GoodsException
([
'cus'
=>
34
]);
}
//判断是否是整数
if
(
!
empty
(
$params
[
"rule_limit"
])
&&
(
!
is_numeric
(
$params
[
"rule_limit"
])
||
strpos
(
$params
[
"rule_limit"
],
"."
)
!==
false
))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
RULE_LIMIT_ERROR
]);
}
$skuParams
=
[
"goods_name"
=>
$params
[
"goods_name"
],
"desc_pic_url"
=>
$params
[
"desc_pic_url"
],
"desc"
=>
$params
[
"desc"
],
"inventory_total"
=>
$skuData
[
"inventory_total"
]
+
$params
[
"inventory_add"
],
"rule_limit"
=>
empty
(
$params
[
"rule_limit"
])
?
0
:
$params
[
"rule_limit"
],
"inventory_total"
=>
$inventoryTotal
,
"ota_id"
=>
empty
(
$params
[
"ota_id"
])
?
0
:
$params
[
"ota_id"
],
"inventory_rest"
=>
$inventoryCount
,
"original_price"
=>
empty
(
$params
[
"original_price"
])
?
""
:
$params
[
"original_price"
]
*
100
,
...
...
application/services/marketing/MarketingForOrderService.php
View file @
781c1560
...
...
@@ -58,10 +58,10 @@ class MarketingForOrderService
$takePlaceList
=
[];
if
(
!
empty
(
$takePlaceIdList
))
{
$takePlaceIdArr
=
array_column
(
$takePlaceIdList
,
"take_place_id"
);
$takePlaceList
=
TakePlace
::
select
([
"take_place_id"
,
"take_place_name"
,
"create_time"
],
[
"take_place_id"
=>
$takePlaceIdArr
]);
$takePlaceList
=
TakePlace
::
select
([
"take_place_id"
,
"take_place_name"
,
"create_time"
,
"address"
],
[
"take_place_id"
=>
$takePlaceIdArr
]);
}
}
else
{
$takePlaceList
=
TakePlace
::
select
([
"take_place_id"
,
"take_place_name"
,
"create_time"
]);
$takePlaceList
=
TakePlace
::
select
([
"take_place_id"
,
"take_place_name"
,
"create_time"
,
"address"
]);
}
return
$takePlaceList
;
}
...
...
application/services/marketing/MarketingService.php
View file @
781c1560
...
...
@@ -4,6 +4,8 @@
namespace
App\Services\marketing
;
use
Api\PhpServices\Ksy\Ks3Api
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Exception\custom\InterfaceException
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\PindanGoodsSku
;
use
App\Models\marketing\mysql\Marketing
;
...
...
@@ -945,6 +947,15 @@ class MarketingService
$info
[
'marketing_info'
]
=
$marketingData
;
//有用户登录时候,当前用户购买的商品数量信息
$haveBuyGoodsStatistics
=
[];
if
(
!
empty
(
$params
[
"user_id"
]))
{
$haveBuyGoodsStatistics
=
self
::
getHaveBuyGoodsStatistics
([
"user_id"
=>
$params
[
"user_id"
],
"marketing_id"
=>
$marketingData
[
"id"
]]);
}
//活动中所有购买的商品数量信息
$allHaveBuyGoodsStatistics
=
self
::
getHaveBuyGoodsStatistics
([
"marketing_id"
=>
$marketingData
[
"id"
]]);
if
(
!
empty
(
$goodsSkuList
))
{
$otaIds
=
array_unique
(
array_column
(
$goodsSkuList
,
"ota_id"
));
$otas
=
Ota
::
select
([
"ota_id"
,
"ota_name"
],
[
"ota_id"
=>
$otaIds
]);
...
...
@@ -957,6 +968,19 @@ class MarketingService
$goodsSkuList
[
$key
][
"ota_name"
]
=
empty
(
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
])
?
""
:
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
];
$goodsSkuList
[
$key
][
"original_price"
]
=
empty
(
$item
[
"original_price"
])
?
''
:
sprintf
(
"%.2f"
,
(
int
)
$item
[
"original_price"
]
/
100
);
$goodsSkuList
[
$key
][
"price"
]
=
sprintf
(
"%.2f"
,
$item
[
"price"
]
/
100
);
$goodsSkuList
[
$key
][
"have_buy_goods_count"
]
=
0
;
//前端当前登录人的数据
$haveBuyGoodsSkuIds
=
array_keys
(
$haveBuyGoodsStatistics
);
if
(
in_array
(
$item
[
"goods_sku_id"
],
$haveBuyGoodsSkuIds
))
{
$goodsSkuList
[
$key
][
"have_buy_goods_count"
]
=
$haveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
//后台展示所有购买的数量
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
0
;
$allHaveBuyGoodsSkuIds
=
array_keys
(
$allHaveBuyGoodsStatistics
);
if
(
in_array
(
$item
[
"goods_sku_id"
],
$allHaveBuyGoodsSkuIds
))
{
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
$allHaveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
}
}
...
...
@@ -1014,4 +1038,24 @@ class MarketingService
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
/**
* 指定活动的已购买商品统计
* @param array $params
* @return array|mixed
* @throws InterfaceException
*/
public
static
function
getHaveBuyGoodsStatistics
(
$params
=
[])
{
$url
=
config
(
'interface'
,
'order.order.have_buy_order_statistics'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$res
=
HttpUtil
::
get
(
$url
,
$params
);
$data
=
[];
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$data
=
$res
[
"response"
][
"result"
];
}
return
$data
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment