-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## 4.4.0 | ||
|
||
- 新增:订单快捷操作工具类 OrderUtil | ||
|
||
--- | ||
|
||
## 4.3.0 移动端链接识别,uniapp操作工具 | ||
|
||
- 新增:有移动端链接时,后台链接选择自动识别电脑端和移动端筛选 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
|
||
namespace Module\Vendor\Util; | ||
|
||
|
||
use ModStart\Core\Dao\ModelUtil; | ||
use ModStart\Core\Exception\BizException; | ||
use Module\Vendor\Type\OrderStatus; | ||
|
||
class OrderUtil | ||
{ | ||
public static function cancelManual($model, $where, $successCallback = null) | ||
{ | ||
ModelUtil::transactionBegin(); | ||
try { | ||
$order = ModelUtil::getWithLock($model, $where); | ||
BizException::throwsIfEmpty('订单不存在', $order); | ||
BizException::throwsIf('订单状态异常', $order['status'] != OrderStatus::WAIT_PAY); | ||
$update = [ | ||
'status' => OrderStatus::CANCEL, | ||
]; | ||
if (array_key_exists('cancelTime', $order)) { | ||
$update['cancelTime'] = date('Y-m-d H:i:s'); | ||
} | ||
ModelUtil::update($model, $order['id'], $update); | ||
call_user_func_array($successCallback, [$order]); | ||
ModelUtil::transactionCommit(); | ||
} catch (BizException $e) { | ||
ModelUtil::transactionRollback(); | ||
throw $e; | ||
} | ||
} | ||
|
||
public static function cancelExpire($model, $where, $successCallback) | ||
{ | ||
ModelUtil::transactionBegin(); | ||
try { | ||
$order = ModelUtil::getWithLock($model, $where); | ||
BizException::throwsIfEmpty('订单不存在', $order); | ||
BizException::throwsIf('订单状态异常', $order['status'] != OrderStatus::WAIT_PAY); | ||
$update = [ | ||
'status' => OrderStatus::CANCEL_EXPIRED, | ||
]; | ||
if (array_key_exists('cancelTime', $order)) { | ||
$update['cancelTime'] = date('Y-m-d H:i:s'); | ||
} | ||
ModelUtil::update($model, $order['id'], $update); | ||
call_user_func_array($successCallback, [$order]); | ||
ModelUtil::transactionCommit(); | ||
} catch (BizException $e) { | ||
ModelUtil::transactionRollback(); | ||
} | ||
} | ||
|
||
public static function payed($model, $where, $successCallback, $updateStatus = null) | ||
{ | ||
if (is_null($updateStatus)) { | ||
$updateStatus = OrderStatus::COMPLETED; | ||
} | ||
ModelUtil::transactionBegin(); | ||
try { | ||
$order = ModelUtil::getWithLock($model, $where); | ||
BizException::throwsIfEmpty('订单不存在', $order); | ||
BizException::throwsIf('订单状态异常', $order['status'] != OrderStatus::WAIT_PAY); | ||
$update = [ | ||
'status' => $updateStatus, | ||
]; | ||
if (array_key_exists('payTime', $order)) { | ||
$update['payTime'] = date('Y-m-d H:i:s'); | ||
} | ||
ModelUtil::update($model, $order['id'], $update); | ||
call_user_func_array($successCallback, [$order]); | ||
ModelUtil::transactionCommit(); | ||
} catch (BizException $e) { | ||
ModelUtil::transactionRollback(); | ||
throw $e; | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.