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
2461212a
Commit
2461212a
authored
Sep 28, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 二手商品add
parent
86860711
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
317 additions
and
0 deletions
+317
-0
ErshouGoodsValidate.php
application/library/Validate/ErshouGoodsValidate.php
+23
-0
ErshouGoodsSku.php
application/models/goods/mysql/ErshouGoodsSku.php
+66
-0
GoodsSpu.php
application/models/goods/mysql/GoodsSpu.php
+1
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+4
-0
ErshouGoodsService.php
application/services/goods/ErshouGoodsService.php
+221
-0
GoodsService.php
application/services/goods/GoodsService.php
+2
-0
No files found.
application/library/Validate/ErshouGoodsValidate.php
0 → 100644
View file @
2461212a
<?php
namespace
Validate
;
/**
* Class ErshouGoodsValidate
*
* @package Validate
*/
class
ErshouGoodsValidate
extends
BaseValidate
{
protected
$rule
=
[
'goods_sub_type'
=>
'require'
,
'sku_json'
=>
'require'
,
];
protected
$message
=
[
'goods_sub_type'
=>
'goods_sub_type 不能为空'
,
'sku_json'
=>
'sku_json 不能为空'
,
];
}
\ No newline at end of file
application/models/goods/mysql/ErshouGoodsSku.php
0 → 100644
View file @
2461212a
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* Class ErshouGoodsSku
* 拼单商品sku信息表
* @package App\Models\goods\mysql
*/
class
ErshouGoodsSku
extends
MysqlBase
{
const
TABLE_NAME
=
'ershou_goods_sku'
;
const
CONFIG_INDEX
=
'goods'
;
const
STATUS_AUDIT
=
0
;
//待审核
const
STATUS_PASS
=
1
;
//审核通过
const
STATUS_REJECT
=
2
;
//审核驳回
const
ONLINE_STATUS_NO_ONLINE
=
0
;
//未上架
const
ONLINE_STATUS_ONLINE
=
1
;
//已上架
const
ONLINE_STATUS_OFFLINE
=
2
;
//已下架
public
static
function
getRecord
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
get
(
$columns
,
$where
,
[]);
}
public
static
function
getRecords
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
select
(
$columns
,
$where
,
[]);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
selectMaster
(
$columns
,
$where
,
[]);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
,
[]);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
public
static
function
getCount
(
$where
,
$columns
=
"*"
)
{
return
self
::
count
(
$columns
,
$where
);
}
}
\ No newline at end of file
application/models/goods/mysql/GoodsSpu.php
View file @
2461212a
...
...
@@ -20,6 +20,7 @@ class GoodsSpu extends MysqlBase
const
SUB_TYPE_TO_SHOP
=
1
;
//到店
const
SUB_TYPE_ONLINE
=
2
;
//线上
const
SUB_TYPE_INSTANT
=
3
;
//即时(外卖)
const
SUB_TYPE_ERSHOU
=
4
;
//二手
const
SALE_TYPE_NO_COMBINATION
=
1
;
//非组合商品(无套餐)
const
SALE_TYPE_COMBINATION
=
2
;
//组合商品(有套餐)
...
...
application/modules/Goods/controllers/Goods.php
View file @
2461212a
...
...
@@ -17,10 +17,12 @@ use \Validate\PaySuccessGoodsCallbackValidate;
use
\Validate\GoodsInitShopValidate
;
use
\Validate\PindanGoodsAddValidate
;
use
\Validate\GoodsOnlineSiteValidate
;
use
\Validate\ErshouGoodsValidate
;
use
\App\Services\goods\ElasticGoodService
;
use
\App\Services\goods\MarketingPindanGoodsService
;
use
\App\Models\marketing\mysql\Marketing
;
use
\App\Services\goods\GoodsSnapshotsService
;
use
\App\Models\goods\mysql\GoodsSpu
;
class
GoodsController
extends
Base
...
...
@@ -53,6 +55,8 @@ class GoodsController extends Base
$params
=
$this
->
params
;
if
(
!
empty
(
$params
[
"marketing_type"
])
&&
$params
[
"marketing_type"
]
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
(
new
PindanGoodsAddValidate
())
->
validate
();
}
elseif
(
!
empty
(
$params
[
"goods_sub_type"
])
&&
$params
[
"goods_sub_type"
]
==
GoodsSpu
::
SUB_TYPE_ERSHOU
)
{
(
new
ErshouGoodsValidate
())
->
validate
();
}
else
{
(
new
GoodsAddValidate
())
->
validate
();
}
...
...
application/services/goods/ErshouGoodsService.php
0 → 100644
View file @
2461212a
<?php
namespace
App\Services\goods
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpServices\Ksy\Ks3Api
;
use
Api\PhpServices\Ksy\Ksyun
;
use
Api\PhpServices\Sensitive\Sensitive
;
use
Api\PhpUtils\Common\BaseConvert
;
use
Api\PhpUtils\Common\GoodsSkuId
;
use
Api\PhpUtils\Http\HttpUtil
;
use
Api\PhpUtils\Lock\FrequencyLockUtil
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Category
;
use
App\Models\goods\mysql\GoodsOperationRecord
;
use
App\Models\goods\mysql\GoodsRefundRecord
;
use
App\Models\goods\mysql\GoodsSku
;
use
App\Models\goods\mysql\GoodsSkuPicRecord
;
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\ErshouGoodsSku
;
use
App\Models\goods\mysql\PindanGoodsSnapshot
;
use
App\Models\goods\mysql\Shop
;
use
App\Models\marketing\mysql\Distributor
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingGoods
;
use
App\Models\shop\mysql\SubShop
;
use
App\Services\marketing\DistributorService
;
use
App\Services\marketing\MarketingGoodsService
;
use
App\Services\marketing\MarketingService
;
use
App\Services\shop\ShopService
;
use
App\Services\common\CommonService
;
use
Api\PhpUtils\Http\Request
;
use
App\Exception\custom\InterfaceException
;
class
ErshouGoodsService
{
/**
* 拼单商品
* @param $arr
* @return string
* @throws GoodsException
* @throws \App\Exception\custom\CodeSpecialException
*/
public
static
function
ershouAddGoods
(
$arr
)
{
GoodsSpu
::
beginTransaction
();
$skuParams
=
json_decode
(
$arr
[
"sku_json"
],
true
);
if
(
!
empty
(
$skuParams
))
{
foreach
(
$skuParams
as
$params
)
{
$userId
=
$params
[
"publish_user_id"
];
}
list
(
$lifeAccountId
,
$merchantId
)
=
self
::
getLifeAccountInfo
(
$userId
);
$lifeAccount
=
[
"life_account_id"
=>
$lifeAccountId
,
"merchant_id"
=>
$merchantId
,
];
foreach
(
$skuParams
as
$params
)
{
//自定义的商品名
$params
[
"life_account_id"
]
=
$lifeAccountId
;
$params
[
"goods_name"
]
=
$lifeAccountId
.
"发布的二手商品"
;
$shopId
=
GoodsService
::
addShop
(
$lifeAccount
);
$spuData
=
self
::
addGoodsSpu
(
$shopId
,
$params
);
$skuId
=
self
::
addGoodsSku
(
$spuData
,
$shopId
,
$params
);
//商品操作记录
$record
=
[
"goods_spu_id"
=>
$spuData
[
"goods_spu_id"
],
"goods_sku_id"
=>
$skuId
,
"operator_id"
=>
empty
(
$params
[
"publish_user_id"
])
?
0
:
$params
[
"publish_user_id"
],
"operator_name"
=>
$params
[
"user_name"
],
"goods_status"
=>
GoodsSku
::
STATUS_PASS
,
"online_status"
=>
GoodsSku
::
ONLINE_STATUS_ONLINE
,
"before_version"
=>
1
,
"after_version"
=>
1
,
"note"
=>
empty
(
$params
[
"rejected_reason"
])
?
""
:
$params
[
"rejected_reason"
],
];
GoodsOperationRecord
::
insertRecord
(
$record
);
}
}
if
(
!
GoodsSpu
::
commit
())
{
GoodsSpu
::
rollback
();
throw
new
GoodsException
([
"cus"
=>
0
]);
}
return
true
;
}
/**
* 获取生活号信息,没有的话默认创建
* @param $userId
* @return array
* @throws GoodsException
* @throws InterfaceException
*/
private
static
function
getLifeAccountInfo
(
$userId
)
{
$url
=
config
(
'interface'
,
'merchant.lifeaccount.get_lid_by_uid'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$res
=
HttpUtil
::
get
(
$url
,
[
"uid"
=>
$userId
]);
$accountRes
=
empty
(
$res
[
"response"
][
"result"
])
?
[]
:
$res
[
"response"
][
"result"
][
0
];
if
(
!
empty
(
$accountRes
))
{
$lifeAccountId
=
$accountRes
[
"life_account_id"
];
$merchantId
=
$accountRes
[
"merchant_id"
];
}
else
{
$url
=
config
(
'interface'
,
'merchant.life_account.create_unauthorized'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$lifeAccountInfo
=
HttpUtil
::
get
(
$url
,
[
"user_id"
=>
$userId
]);
$lifeAccountId
=
empty
(
$lifeAccountInfo
[
"life_account_id"
])
?
""
:
$lifeAccountInfo
[
"life_account_id"
];
$merchantId
=
empty
(
$lifeAccountInfo
[
"merchant_id"
])
?
""
:
$lifeAccountInfo
[
"merchant_id"
];
if
(
empty
(
$lifeAccountId
)
||
empty
(
$merchantId
))
{
throw
new
GoodsException
([
'cus'
=>
0
]);
}
}
return
[
$lifeAccountId
,
$merchantId
];
}
/**
* 添加spu
* @param $shopId
* @param array $spuData
* @return mixed
* @throws GoodsException
*/
private
static
function
addGoodsSpu
(
$shopId
,
$spuData
=
[])
{
$spu
=
GoodsSpu
::
get
(
"*"
,
[
"goods_name"
=>
$spuData
[
"goods_name"
],
"life_account_id"
=>
$spuData
[
"life_account_id"
]]);
if
(
!
empty
(
$spu
))
{
return
$spu
;
}
$res
=
GoodsService
::
getIdgenId
(
substr
(
$shopId
,
-
2
),
"goods"
);
if
(
empty
(
$res
))
{
throw
new
GoodsException
([
'cus'
=>
2
]);
}
$spuId
=
$res
[
0
];
$spuParams
=
[
"goods_spu_id"
=>
$spuId
,
"shop_id"
=>
$shopId
,
"life_account_id"
=>
$spuData
[
"life_account_id"
],
"publish_user_id"
=>
$spuData
[
"publish_user_id"
],
"goods_name"
=>
$spuData
[
"goods_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_ERSHOU
:
$spuData
[
"goods_sub_type"
],
"belong_type"
=>
empty
(
$spuData
[
"belong_type"
])
?
GoodsSpu
::
BELONG_TYPE_DISANFANG
:
$spuData
[
"belong_type"
],
"goods_sale_type"
=>
empty
(
$spuData
[
"setmeal"
])
?
GoodsSpu
::
SALE_TYPE_NO_COMBINATION
:
GoodsSpu
::
SALE_TYPE_COMBINATION
,
"can_show_es"
=>
GoodsSpu
::
CAN_SHOW_ES_NO
,
];
GoodsSpu
::
save
(
$spuParams
);
return
$spuParams
;
}
/**
* 添加拼单活动sku
* @param $spuData
* @param $shopId
* @param array $skuData
* @return string
* @throws GoodsException
* @throws \App\Exception\custom\CodeSpecialException
*/
private
static
function
addGoodsSku
(
$spuData
,
$shopId
,
$skuData
=
[])
{
$res
=
GoodsService
::
getIdgenId
(
substr
(
$shopId
,
-
2
),
"goods"
);
if
(
empty
(
$res
))
{
throw
new
GoodsException
([
'cus'
=>
2
]);
}
$skuId
=
GoodsSkuId
::
generateGoodSkuId
(
$res
[
0
],
"00"
,
"000"
,
$spuData
[
"goods_type"
],
$spuData
[
"belong_type"
],
"002"
);
$checkGoodsDesc
=
GoodsService
::
isHaveSensitive
(
$skuData
[
"desc"
],
2
);
if
(
$checkGoodsDesc
)
{
throw
new
GoodsException
([
'cus'
=>
20
]);
}
$skuParams
=
[
"goods_sku_id"
=>
$skuId
,
"goods_spu_id"
=>
$spuData
[
"goods_spu_id"
],
"life_account_id"
=>
$skuData
[
"life_account_id"
],
"publish_user_id"
=>
empty
(
$skuData
[
"publish_user_id"
])
?
""
:
$skuData
[
"publish_user_id"
],
"category_1_id"
=>
0
,
"category_2_id"
=>
0
,
"goods_name"
=>
$skuData
[
"goods_name"
],
"desc_pic_url"
=>
$skuData
[
"desc_pic_url"
],
"desc"
=>
$skuData
[
"desc"
],
"original_price"
=>
empty
(
$skuData
[
"price"
])
?
""
:
$skuData
[
"price"
]
*
100
,
"price"
=>
empty
(
$skuData
[
"price"
])
?
""
:
$skuData
[
"price"
]
*
100
,
"audit_status"
=>
ErshouGoodsSku
::
STATUS_AUDIT
,
"online_status"
=>
ErshouGoodsSku
::
ONLINE_STATUS_NO_ONLINE
,
"location_name"
=>
empty
(
$skuData
[
"location_name"
])
?
""
:
$skuData
[
"location_name"
],
"longitude"
=>
empty
(
$skuData
[
"longitude"
])
?
""
:
$skuData
[
"longitude"
],
"latitude"
=>
empty
(
$skuData
[
"latitude"
])
?
""
:
$skuData
[
"latitude"
],
"address"
=>
empty
(
$skuData
[
"address"
])
?
""
:
$skuData
[
"address"
],
"province"
=>
empty
(
$skuData
[
"province"
])
?
""
:
$skuData
[
"province"
],
"city"
=>
empty
(
$skuData
[
"city"
])
?
""
:
$skuData
[
"city"
],
"area"
=>
empty
(
$skuData
[
"area"
])
?
""
:
$skuData
[
"area"
],
];
$res
=
ErshouGoodsSku
::
save
(
$skuParams
);
if
(
$res
===
false
)
{
GoodsSpu
::
rollback
();
throw
new
GoodsException
([
"cus"
=>
0
]);
}
GoodsService
::
addGoodsSkuPicRecord
(
$skuId
,
$skuData
);
return
$skuId
;
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
2461212a
...
...
@@ -84,6 +84,8 @@ class GoodsService
$marketingType
=
!
empty
(
$params
[
'marketing_type'
])
?
$params
[
'marketing_type'
]
:
0
;
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
return
MarketingPindanGoodsService
::
pindanMarketingAddGoods
(
$params
);
}
elseif
(
!
empty
(
$params
[
"goods_sub_type"
])
&&
$params
[
"goods_sub_type"
]
==
GoodsSpu
::
SUB_TYPE_ERSHOU
)
{
return
ErshouGoodsService
::
ershouAddGoods
(
$params
);
}
else
{
return
self
::
generalAddGoods
(
$params
);
}
...
...
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