|
|
@@ -16,20 +16,31 @@ class SettleController extends BaseController
|
|
|
//结清尾款 ssh 20220708
|
|
|
public function actionConfirmSettle()
|
|
|
{
|
|
|
- die;
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- $id = $get['id'] ?? 0;
|
|
|
- $payWay = $get['payWay'] ?? dict::getDict('payWay', 'wxPay');
|
|
|
- $order = OrderClass::getById($id, true);
|
|
|
- if (empty($order)) {
|
|
|
- util::fail('没有找到订单');
|
|
|
- }
|
|
|
- OrderClass::valid($order, $this->mainId);
|
|
|
- $staff = $this->shopAdmin;
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- SettleClass::confirmSettle($order, $payWay, $staff);
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ $payWay = $post['payWay'] ?? dict::getDict('payWay', 'wxPay');
|
|
|
+ $id = $post['id'] ?? '';
|
|
|
+ if (is_numeric($id)) {
|
|
|
+ $order = OrderClass::getById($id, true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ OrderClass::valid($order, $this->mainId);
|
|
|
+ SettleClass::confirmSettle($order, $payWay, $staff);
|
|
|
+ } else {
|
|
|
+ $idArr = json_decode($id, true);
|
|
|
+ $ids = array_column($idArr, 'id');
|
|
|
+ $orderList = OrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
|
|
|
+ if (!empty($orderList)) {
|
|
|
+ foreach ($orderList as $order) {
|
|
|
+ OrderClass::valid($order, $this->mainId);
|
|
|
+ SettleClass::confirmSettle($order, $payWay, $staff);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
$transaction->commit();
|
|
|
util::complete();
|
|
|
} catch (\Exception $exception) {
|