0) { $count = DataUserTransfer::mk()->whereRaw("uuid='{$uuid}' and status>0")->sum('amount'); $total = DataUserRebate::mk()->whereRaw("uuid='{$uuid}' and status=1 and deleted=0")->sum('amount'); $locks = DataUserRebate::mk()->whereRaw("uuid='{$uuid}' and status=0 and deleted=0")->sum('amount'); DataUser::mk()->where(['id' => $uuid])->update(['rebate_total' => $total, 'rebate_used' => $count, 'rebate_lock' => $locks]); } else { $count = DataUserTransfer::mk()->whereRaw("status>0")->sum('amount'); $total = DataUserRebate::mk()->whereRaw("status=1 and deleted=0")->sum('amount'); $locks = DataUserRebate::mk()->whereRaw("status=0 and deleted=0")->sum('amount'); } return [$total, $count, $locks]; } /** * 确认收货订单处理 * @param string $orderNo * @return array [status, message] * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function confirm(string $orderNo): array { $map = [['status', '>=', 4], ['order_no', '=', $orderNo]]; $order = ShopOrder::mk()->where($map)->findOrEmpty()->toArray(); if (empty($order)) return [0, '需处理的订单状态异常!']; $map = [['status', '=', 0], ['order_no', 'like', "{$orderNo}%"]]; DataUserRebate::mk()->where($map)->update(['status' => 1]); if (UserUpgradeService::upgrade($order['uuid'])) { return [1, '重新计算用户金额成功!']; } else { return [0, '重新计算用户金额失败!']; } } }