|
|
@@ -55,54 +55,63 @@ class RechargeController extends BaseController
|
|
|
$staffId = $shopAdmin->id;
|
|
|
$staffName = $shopAdmin->name;
|
|
|
|
|
|
- $payWay = $post['payWay'] ?? 0;
|
|
|
- $amount = $post['amount'] ?? 0;
|
|
|
- $remark = $post['remark'] ?? '';
|
|
|
- $customId = $post['customId'] ?? 0;
|
|
|
- $custom = \bizHd\custom\classes\CustomClass::getById($customId, true);
|
|
|
- if (empty($custom)) {
|
|
|
- util::fail('没有找到客户');
|
|
|
- }
|
|
|
- $customName = $custom->name;
|
|
|
- $hdId = $custom->hdId;
|
|
|
- $hd = HdClass::getById($hdId, true);
|
|
|
- if (empty($hd)) {
|
|
|
- util::fail('花店信息缺失');
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $payWay = $post['payWay'] ?? 0;
|
|
|
+ $amount = $post['amount'] ?? 0;
|
|
|
+ $remark = $post['remark'] ?? '';
|
|
|
+ $customId = $post['customId'] ?? 0;
|
|
|
+ $custom = \bizHd\custom\classes\CustomClass::getById($customId, true);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('没有找到客户');
|
|
|
+ }
|
|
|
+ $customName = $custom->name;
|
|
|
+ $hdId = $custom->hdId;
|
|
|
+ $hd = HdClass::getById($hdId, true);
|
|
|
+ if (empty($hd)) {
|
|
|
+ util::fail('花店信息缺失');
|
|
|
+ }
|
|
|
+ $hdName = $hd->name;
|
|
|
+ $shopId = $this->shopId;
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $orderSn = orderSn::getRechargeSn();
|
|
|
+ $rechargeData = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'modPrice' => 1,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'hdId' => $hdId,
|
|
|
+ 'hdName' => $hdName,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'payStatus' => 0,
|
|
|
+ 'payTime' => '0000-00-00 00:00:00',
|
|
|
+ 'status' => 0,
|
|
|
+ 'remark' => $remark,
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'customName' => $customName,
|
|
|
+ ];
|
|
|
+ $respond = \bizHd\recharge\classes\RechargeClass::addRecharge($rechargeData);
|
|
|
+
|
|
|
+ $id = $respond->id;
|
|
|
+ $recharge = RechargeClass::getLockById($id);
|
|
|
+ $params = [
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'side' => 0,
|
|
|
+ ];
|
|
|
+ \bizHd\recharge\classes\RechargeClass::complete($recharge, $payWay, $params);
|
|
|
+ $transaction->commit();
|
|
|
+ util::success($post);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::error("充值失败原因:" . $e->getMessage());
|
|
|
+ util::fail('充值失败');
|
|
|
}
|
|
|
- $hdName = $hd->name;
|
|
|
- $shopId = $this->shopId;
|
|
|
- $mainId = $this->mainId;
|
|
|
- $orderSn = orderSn::getRechargeSn();
|
|
|
- $rechargeData = [
|
|
|
- 'orderSn' => $orderSn,
|
|
|
- 'modPrice' => 1,
|
|
|
- 'payWay' => $payWay,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'mainId' => $mainId,
|
|
|
- 'hdId' => $hdId,
|
|
|
- 'hdName' => $hdName,
|
|
|
- 'onlinePay' => 1,
|
|
|
- 'amount' => $amount,
|
|
|
- 'staffId' => $staffId,
|
|
|
- 'staffName' => $staffName,
|
|
|
- 'payStatus' => 0,
|
|
|
- 'payTime' => '0000-00-00 00:00:00',
|
|
|
- 'status' => 0,
|
|
|
- 'remark' => $remark,
|
|
|
- 'customId' => $customId,
|
|
|
- 'customName' => $customName,
|
|
|
- ];
|
|
|
- $respond = \bizHd\recharge\classes\RechargeClass::addRecharge($rechargeData);
|
|
|
-
|
|
|
- $id = $respond->id;
|
|
|
- $recharge = RechargeClass::getLockById($id);
|
|
|
- $params = [
|
|
|
- 'onlinePay' => 1,
|
|
|
- 'side' => 0,
|
|
|
- ];
|
|
|
- \bizHd\recharge\classes\RechargeClass::complete($recharge, $payWay, $params);
|
|
|
-
|
|
|
- util::success($post);
|
|
|
}
|
|
|
|
|
|
//充值记录 ssh 2021.2.21
|