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
468221ff
Commit
468221ff
authored
Jul 15, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test'
parents
f3156032
1d874d89
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
69 deletions
+77
-69
PaySuccessGoodsCallbackValidate.php
...tion/library/Validate/PaySuccessGoodsCallbackValidate.php
+4
-6
GoodsService.php
application/services/goods/GoodsService.php
+51
-41
MarketingService.php
application/services/marketing/MarketingService.php
+14
-5
Goods.php
daemon/Goods.php
+2
-7
Marketing.php
daemon/Marketing.php
+6
-10
No files found.
application/library/Validate/PaySuccessGoodsCallbackValidate.php
View file @
468221ff
...
...
@@ -12,14 +12,12 @@ namespace Validate;
class
PaySuccessGoodsCallbackValidate
extends
BaseValidate
{
protected
$rule
=
[
'pay_order_id'
=>
'require'
,
'goods_sku_id'
=>
'require'
,
'num'
=>
'require'
,
'order_id'
=>
'require'
,
'goods'
=>
'require'
,
];
protected
$message
=
[
"pay_order_id"
=>
"pay_order_id 不能为空"
,
"goods_sku_id"
=>
"goods_sku_id 不能为空"
,
"num"
=>
"商品数量不能为空"
,
"order_id"
=>
"order_id 不能为空"
,
"goods"
=>
"goods 信息不能为空"
,
];
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
468221ff
...
...
@@ -355,7 +355,7 @@ class GoodsService
}
$goodsSkuId
=
$sku
[
"goods_sku_id"
];
$rejectedReason
=
empty
(
$params
[
"rejected_reason"
])
?
""
:
$params
[
"rejected_reason"
];
$rejectedReason
=
strlen
(
trim
(
$params
[
"rejected_reason"
]))
==
0
?
""
:
$params
[
"rejected_reason"
];
if
(
$status
==
GoodsSku
::
STATUS_PASS
)
{
$statusData
=
[
"online_status"
=>
GoodsSku
::
ONLINE_STATUS_ONLINE
,
...
...
@@ -769,7 +769,7 @@ class GoodsService
}
}
}
$recordList
=
GoodsOperationRecord
::
select
(
"*"
,
[
"goods_spu_id"
=>
$goodsSpuId
,
"ORDER"
=>
[
"create_time"
=>
"DESC"
]]);
$recordList
=
GoodsOperationRecord
::
select
(
"*"
,
[
"goods_spu_id"
=>
$goodsSpuId
,
"ORDER"
=>
[
"create_time"
=>
"DESC"
]]);
if
(
!
empty
(
$recordList
))
{
foreach
(
$recordList
as
$key
=>
$record
)
{
$data
[
"record_list"
][
$key
][
"status"
]
=
$record
[
"goods_status"
];
...
...
@@ -824,7 +824,7 @@ class GoodsService
$data
[
"goods_info"
][
"rule"
][
"rule_limit"
]
=
$sku
[
"rule_limit"
];
$data
[
"goods_info"
][
"rule"
][
"rule_refund"
]
=
$ruleRefundDesc
;
$data
[
"goods_info"
][
"rule"
][
"rule_date_type"
]
=
$ruleDateTypeDesc
;
$data
[
"goods_info"
][
"rule"
][
"rule_time"
]
=
date
(
'H:i'
,
strtotime
(
$sku
[
"rule_start_time"
]))
.
" ~ "
.
date
(
'H:i'
,
strtotime
(
$sku
[
"rule_end_time"
]));
$data
[
"goods_info"
][
"rule"
][
"rule_time"
]
=
date
(
'H:i'
,
strtotime
(
$sku
[
"rule_start_time"
]))
.
" ~ "
.
date
(
'H:i'
,
strtotime
(
$sku
[
"rule_end_time"
]));
$data
[
"goods_info"
][
"rule"
][
"rule_desc"
]
=
$sku
[
"rule_desc"
];
$data
[
"goods_info"
][
"rule"
][
"expiration_time"
]
=
$sku
[
"expiration_time"
];
...
...
@@ -905,7 +905,7 @@ class GoodsService
$status
=
explode
(
","
,
$params
[
"audit_status"
]);
$where
[
"audit_status"
]
=
$status
;
}
if
(
!
empty
(
$params
[
"online_status"
])
||
(
isset
(
$params
[
"online_status"
])
&&
$params
[
"online_status"
]
===
'0'
))
{
if
(
!
empty
(
$params
[
"online_status"
])
||
(
isset
(
$params
[
"online_status"
])
&&
$params
[
"online_status"
]
===
'0'
))
{
$onlineStatus
=
explode
(
","
,
$params
[
"online_status"
]);
$where
[
"online_status"
]
=
$onlineStatus
;
}
...
...
@@ -975,6 +975,7 @@ class GoodsService
$data
=
[];
if
(
!
empty
(
$list
))
{
$count
=
count
(
$list
);
foreach
(
$list
as
$key
=>
$sku
)
{
$sku
[
"original_price"
]
=
$sku
[
"original_price"
]
/
100
;
$sku
[
"price"
]
=
$sku
[
"price"
]
/
100
;
...
...
@@ -986,6 +987,9 @@ class GoodsService
}
$lastId
=
$sku
[
"goods_spu_id"
];
}
if
(
$count
<
$limit
)
{
$lastId
=
"-1"
;
}
}
else
{
$lastId
=
"-1"
;
}
...
...
@@ -1017,7 +1021,7 @@ class GoodsService
if
(
!
empty
(
$subShopList
))
{
foreach
(
$subShopList
as
$subShop
)
{
if
(
!
empty
(
$subShop
[
"latitude"
])
&&
!
empty
(
$subShop
[
"longitude"
]))
{
$esId
=
$goodsSkuInfo
[
"goods_sku_id"
]
.
"_"
.
$subShop
[
"sub_shop_id"
];
$esId
=
$goodsSkuInfo
[
"goods_sku_id"
]
.
"_"
.
$subShop
[
"sub_shop_id"
];
$data
=
[
"doc"
=>
[
"goods_sku_id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
...
...
@@ -1040,7 +1044,7 @@ class GoodsService
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"shop_name"
=>
$subShop
[
"shop_name"
],
"shop_address"
=>
$subShop
[
"address"
],
"shop_location"
=>
$subShop
[
"latitude"
]
.
","
.
$subShop
[
"longitude"
],
"shop_location"
=>
$subShop
[
"latitude"
]
.
","
.
$subShop
[
"longitude"
],
"update_time"
=>
strtotime
(
$goodsSkuInfo
[
"update_time"
]),
],
];
...
...
@@ -1225,8 +1229,8 @@ class GoodsService
}
$info
=
GoodsSku
::
getRecord
(
$where
);
$info
[
'original_price'
]
=
empty
(
$info
[
'original_price'
])
?
0
:
$info
[
'original_price'
]
/
100
;
$info
[
'price'
]
=
!
empty
(
$info
[
'price'
])
?
$info
[
'price'
]
/
100
:
0
;
$info
[
'original_price'
]
=
empty
(
$info
[
'original_price'
])
?
0
:
$info
[
'original_price'
]
/
100
;
$info
[
'price'
]
=
!
empty
(
$info
[
'price'
])
?
$info
[
'price'
]
/
100
:
0
;
$info
[
'desc_pic_url'
]
=
!
empty
(
$info
[
'desc_pic_url'
])
?
self
::
getUrlList
(
$info
[
'desc_pic_url'
])
:
''
;
$info
[
'introduce_pic_url'
]
=
!
empty
(
$info
[
'introduce_pic_url'
])
?
self
::
getUrlList
(
$info
[
'introduce_pic_url'
])
:
""
;
return
$info
;
...
...
@@ -1283,7 +1287,7 @@ class GoodsService
if
(
empty
(
$params
))
{
return
[];
}
if
(
!
empty
(
$params
[
'goods_spu_id'
]))
{
$where
[
'goods_spu_id'
]
=
$params
[
'goods_spu_id'
];
}
...
...
@@ -1353,46 +1357,52 @@ class GoodsService
*/
public
static
function
paySuccessGoodsCallback
(
$params
=
[])
{
$payOrderId
=
$params
[
"pay_order_id"
];
$goodsSkuId
=
$params
[
"goods_sku_id"
];
$num
=
$params
[
"num"
];
$record
=
PaySuccessGoodsCallbackRecord
::
getRecord
([
"pay_order_id"
=>
$payOrderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_SUCCESS
]
);
if
(
empty
(
$record
))
{
GoodsSku
::
beginTransaction
();
$goodsSku
=
GoodsSku
::
getRecord
([
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
empty
(
$goodsSku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
GoodsSku
::
save
([
"total_amount_sold"
=>
$goodsSku
[
"total_amount_sold"
]
+
$num
]
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
$orderId
=
$params
[
"order_id"
];
$goodsPayInfos
=
json_decode
(
$params
[
"goods"
],
true
);
PaySuccessGoodsCallbackRecord
::
insertRecord
([
"pay_order_id"
=>
$payOrderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_SUCCESS
]
GoodsSku
::
beginTransaction
();
foreach
(
$goodsPayInfos
as
$goodsSkuId
=>
$num
)
{
$record
=
PaySuccessGoodsCallbackRecord
::
getRecord
([
"order_id"
=>
$orderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_SUCCESS
]
);
if
(
empty
(
$record
))
{
$goodsSku
=
GoodsSku
::
getRecord
([
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
empty
(
$goodsSku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
if
(
!
GoodsSku
::
commit
())
{
GoodsSku
::
rollback
(
);
GoodsSku
::
save
([
"total_amount_sold"
=>
$goodsSku
[
"total_amount_sold"
]
+
$num
]
,
[
"goods_sku_id"
=>
$goodsSkuId
]
);
PaySuccessGoodsCallbackRecord
::
insertRecord
([
"
pay_order_id"
=>
$payO
rderId
,
"
order_id"
=>
$o
rderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"num"
=>
$num
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_SUCCESS
]
);
}
}
if
(
!
GoodsSku
::
commit
())
{
GoodsSku
::
rollback
();
foreach
(
$goodsPayInfos
as
$goodsSkuId
=>
$num
)
{
PaySuccessGoodsCallbackRecord
::
insertRecord
([
"order_id"
=>
$orderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"num"
=>
$num
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_FAIL
]
);
return
false
;
}
return
false
;
}
else
{
//同步到es
self
::
updateGoodsInfoToEs
(
$goodsSkuId
);
foreach
(
$goodsPayInfos
as
$goodsSkuId
=>
$num
)
{
self
::
updateGoodsInfoToEs
(
$goodsSkuId
);
}
}
return
true
;
}
...
...
@@ -1411,14 +1421,14 @@ class GoodsService
$introducePicUrl
=
explode
(
","
,
$skuData
[
"introduce_pic_url"
]);
}
$ids
=
GoodsSkuPicRecord
::
select
(
"id"
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
GoodsSkuPicRecord
::
delete
([
"id"
=>
$ids
]);
$ids
=
GoodsSkuPicRecord
::
select
(
"id"
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
GoodsSkuPicRecord
::
delete
([
"id"
=>
$ids
]);
$urlList
=
array_unique
(
array_merge
(
$descPicUrl
,
$introducePicUrl
));
$data
=
[];
if
(
!
empty
(
$urlList
))
{
foreach
(
$urlList
as
$url
)
{
$data
[]
=
[
"goods_sku_id"
=>
$goodsSkuId
,
"url"
=>
$url
];
$data
[]
=
[
"goods_sku_id"
=>
$goodsSkuId
,
"url"
=>
$url
];
}
GoodsSkuPicRecord
::
save
(
$data
);
}
...
...
application/services/marketing/MarketingService.php
View file @
468221ff
...
...
@@ -142,11 +142,17 @@ class MarketingService
if
(
!
empty
(
$params
[
'goods_sku_id'
]))
{
$goodsSkuId
=
$params
[
'goods_sku_id'
];
$marketingGoodsList
=
MarketingGoods
::
marketingGoodsList
([
'goods_sku_id'
=>
$goodsSkuId
]);
$marketingId
=
array_column
(
$marketingGoodsList
,
'marketing_id'
);
if
(
!
empty
(
$where
[
'marketing_id'
]))
{
array_push
(
$marketingId
,
$where
[
'marketing_id'
]);
if
(
empty
(
$marketingGoodsList
))
{
$where
[
'marketing_id'
]
=
"-1"
;
}
else
{
$marketingId
=
array_column
(
$marketingGoodsList
,
'marketing_id'
);
if
(
!
empty
(
$where
[
'marketing_id'
]))
{
array_push
(
$marketingId
,
$where
[
'marketing_id'
]);
}
$where
[
'marketing_id'
]
=
$marketingId
;
}
$where
[
'marketing_id'
]
=
$marketingId
;
}
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
...
...
@@ -227,7 +233,6 @@ class MarketingService
throw
new
MarketingException
([
'cus'
=>
14
]);
}
$tmpMarketingId
=
[];
$tmpGoodsSkuId
=
[];
$goodsData
=
[
...
...
@@ -235,8 +240,12 @@ class MarketingService
"start_time[>=]"
=>
$startTime
,
"end_time[>=]"
=>
$startTime
,
],
"online_status"
=>
1
,
];
//存在的活动
$tmpMarketingList
=
Marketing
::
getMarketingList
(
$goodsData
);
if
(
!
empty
(
$tmpMarketingList
))
{
$tmpMarketingId
=
array_column
(
$tmpMarketingList
,
'marketing_id'
);
}
...
...
daemon/Goods.php
View file @
468221ff
...
...
@@ -6,14 +6,9 @@ namespace Daemon;
use
Api\PhpServices\Daemon\DaemonServiceInterface
;
use
App\Models\goods\mysql\GoodsSku
;
use
Api\PhpUtils\Log\
File
Log
;
use
Api\PhpUtils\Log\
Daemon
Log
;
class
Goods
implements
DaemonServiceInterface
{
public
function
__construct
(
int
$mid
)
{
$this
->
mid
=
$mid
;
}
public
function
run
()
{
sleep
(
2
);
...
...
@@ -22,7 +17,7 @@ class Goods implements DaemonServiceInterface
'expiration_time[<]'
=>
date
(
"Y-m-d H:i:s"
,
time
())
];
$goodsList
=
GoodsSku
::
getRecords
(
$orderData
);
File
Log
::
info
(
'DaemonServiceInterface_goods'
,
json_encode
(
$goodsList
));
Daemon
Log
::
info
(
'DaemonServiceInterface_goods'
,
json_encode
(
$goodsList
));
foreach
(
$goodsList
as
$key
=>
$value
)
{
$where
=
[];
$where
[
'goods_sku_id'
]
=
!
empty
(
$value
[
'goods_sku_id'
])
?
$value
[
'goods_sku_id'
]
:
''
;
...
...
daemon/Marketing.php
View file @
468221ff
...
...
@@ -5,15 +5,11 @@ namespace Daemon;
use
Api\PhpServices\Daemon\DaemonServiceInterface
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\Marketing
as
MarketingDao
;
use
Api\PhpUtils\Log\DaemonLog
;
class
Marketing
implements
DaemonServiceInterface
{
const
EXPIRE_DATA
=
86400
;
public
function
__construct
(
int
$mid
)
{
$this
->
mid
=
$mid
;
}
public
function
run
()
{
sleep
(
2
);
...
...
@@ -21,15 +17,15 @@ class Marketing implements DaemonServiceInterface
'online_status'
=>
1
,
'end_time[<]'
=>
date
(
"Y-m-d H:i:s"
,
time
())
];
$orderInfoList
=
Marketing
::
getMarketingList
(
$orderData
);
$orderInfoList
=
MarketingDao
::
getMarketingList
(
$orderData
);
DaemonLog
::
info
(
'DaemonServiceInterface_marketing'
,
json_encode
(
$orderInfoList
));
foreach
(
$orderInfoList
as
$key
=>
$value
)
{
$where
=
[];
$where
[
'marketing_id'
]
=
!
empty
(
$value
[
'marketing_id'
])
?
$value
[
'marketing_id'
]
:
''
;
$colums
=
[
'online_status'
=>
3
,
];
Marketing
::
updateRecord
(
$colums
,
$where
);
Marketing
Dao
::
updateRecord
(
$colums
,
$where
);
}
}
...
...
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