|
|
@@ -39,6 +39,43 @@ class OrderController extends BaseController
|
|
|
|
|
|
public $guestAccess = ['order-relate', 'fast-pay', 'create-order', 'list'];
|
|
|
|
|
|
+ public function actionDebt()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $info = OrderClass::getById($id, true);
|
|
|
+ if (empty($info)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ if ($info->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的订单');
|
|
|
+ }
|
|
|
+
|
|
|
+ //4秒内不允许重复提交
|
|
|
+ $cacheKey = 'ls_set_order_debt_' . $id;
|
|
|
+ $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (!empty($has)) {
|
|
|
+ util::fail('请稍等');
|
|
|
+ }
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
|
|
|
+ if ($info->status != 1) {
|
|
|
+ util::fail('订单已付款或取消');
|
|
|
+ }
|
|
|
+ $payWay = dict::getDict('payWay', 'debtPay');
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderClass::payAfter($info, $payWay);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('已赊账');
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("赊账失败原因:" . $exception->getMessage());
|
|
|
+ util::fail('操作失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//取消订单 ssh 20221231
|
|
|
public function actionCancel()
|
|
|
{
|